Click here to Skip to main content
15,897,187 members
Articles / Web Development / ASP.NET

Take MVC to the Next Level in .NET

Rate me:
Please Sign up or sign in to vote.
4.62/5 (11 votes)
30 Apr 2013GPL315 min read 73.3K   858   75  
How to quickly build reusable and flexible WPF, Silverlight, or ASP.NET applications with the powerful Xomega Framework using the best MVVM principles.
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by an Xomega.Net generator.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using MyProject4.Enumerations;
using MyProject4.Services;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using Xomega.Framework;
using Xomega.Framework.Services;

namespace MyProject4.Entities.Services
{
    public class StoreService : EntityServiceBase<MyProject4Entities>, IStoreService
    {
        public StoreService()
        {
        }

        public virtual StoreKey Create()
        {
            StoreKey res = new StoreKey();
            Store obj = new Store();
            objCtx.AddToStore(obj);
            res.TemporaryKey = TempKeyId(obj);
            return res;
        }

        public virtual Store_ReadOutput Read(StoreKey input)
        {
            Store_ReadOutput res = new Store_ReadOutput();
            EntityKey key = GetEntityKey(typeof(Store), input.TemporaryKey, input.CustomerId);
            Store obj = objCtx.GetObjectByKey(key) as Store;
            ServiceUtil.CopyProperties(obj, res);
            if (obj.EntityState != EntityState.Added)
              obj.SalesPersonIdObjectReference.Load();
            if (obj.SalesPersonIdObject != null)
              res.SalesPersonId = obj.SalesPersonIdObject.SalesPersonId;
            return res;
        }

        public virtual void Update(Store_UpdateInput input)
        {
            EntityKey key = GetEntityKey(typeof(Store), input.TemporaryKey, input.CustomerId);
            Store obj = objCtx.GetObjectByKey(key) as Store;
            ServiceUtil.CopyProperties(input, obj);
            if (input.SalesPersonId != null)
            {
                EntityKey keySalesPersonId = GetEntityKey(typeof(SalesPerson), 0, input.SalesPersonId);
                obj.SalesPersonIdObject = objCtx.GetObjectByKey(keySalesPersonId) as SalesPerson;
            }
            else obj.SalesPersonIdObject = null;
        }

        public virtual void Delete(StoreKey input)
        {
            EntityKey key = GetEntityKey(typeof(Store), input.TemporaryKey, input.CustomerId);
            Store obj = objCtx.GetObjectByKey(key) as Store;
            objCtx.DeleteObject(obj);
        }

        public virtual List<Store_ReadListOutput> ReadList(Store_ReadListInput input)
        {
            List<Store_ReadListOutput> res = new List<Store_ReadListOutput>();
            var qry = from obj in objCtx.Store
                      select new Store_ReadListOutput() {
                          CustomerId = obj.CustomerId,
                          Name = obj.Name,
                          SalesPersonId = obj.SalesPersonIdObject.SalesPersonId,
                      };

            if (input.Customer != null)
                ;// qry = qry.WhereIn(o => o.Customer, input.Customer); /*[TODO: use the right field]*/

            if (input.CreatedDateFrom != null)
                ;// qry = qry.Where(o => o.CreatedDateFrom == input.CreatedDateFrom); /*[TODO: use the right field]*/

            if (input.CreatedDateTo != null)
                ;// qry = qry.Where(o => o.CreatedDateTo == input.CreatedDateTo); /*[TODO: use the right field]*/

            res = qry.ToList();
            return res;
        }

    }

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Architect Xomega.Net
United States United States
Xomega Team is striving to increase productivity and development quality by utilizing Model Driven Development coupled with Code Generation and the best design practices for application development.
We provide MDD tools, code generators and frameworks for Visual Studio and .Net development.
Visit us at http://www.xomega.net
This is a Organisation

1 members

Comments and Discussions