PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 5ms RepoModel.GetById 35ms app.codeStats 0ms

/TimeSheetReporting/TimeSheetReporting.Web/Service/TimeSheetService.cs

#
C# | 96 lines | 68 code | 14 blank | 14 comment | 8 complexity | 18347b1c7dfc3d9894a8dc0cf293ff2d MD5 | raw file
 1
 2namespace TimeSheetReporting.Web.Service
 3{
 4    using System;
 5    using System.Collections.Generic;
 6    using System.ComponentModel;
 7    using System.ComponentModel.DataAnnotations;
 8    using System.Data;
 9    using System.Linq;
10    using System.Web.DomainServices;
11    using System.Web.DomainServices.Providers;
12    using System.Web.Ria;
13    using System.Web.Ria.Services;
14    using TimeSheetReporting.Web.Model;
15
16
17    // Implements application logic using the TimeSheetDatabaseEntities context.
18    // TODO: Add your application logic to these methods or in additional methods.
19    // TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access
20    // Also consider adding roles to restrict access as appropriate.
21    // [RequiresAuthentication]
22    [EnableClientAccess()]
23    public class TimeSheetService : LinqToEntitiesDomainService<TimeSheetDatabaseEntities>
24    {
25
26        // TODO: Consider
27        // 1. Adding parameters to this method and constraining returned results, and/or
28        // 2. Adding query methods taking different parameters.
29        public IQueryable<Effort> GetEffort()
30        {
31            return this.ObjectContext.Effort;
32        }
33
34        public void InsertEffort(Effort effort)
35        {
36            this.ObjectContext.AddToEffort(effort);
37        }
38
39        public void UpdateEffort(Effort currentEffort)
40        {
41            if ((currentEffort.EntityState == EntityState.Detached))
42            {
43                this.ObjectContext.AttachAsModified(currentEffort, this.ChangeSet.GetOriginal(currentEffort));
44            }
45        }
46
47        public void DeleteEffort(Effort effort)
48        {
49            if ((effort.EntityState == EntityState.Detached))
50            {
51                this.ObjectContext.Attach(effort);
52            }
53            this.ObjectContext.DeleteObject(effort);
54        }
55
56        // TODO: Consider
57        // 1. Adding parameters to this method and constraining returned results, and/or
58        // 2. Adding query methods taking different parameters.
59        public IQueryable<Member> GetMember()
60        {
61            return this.ObjectContext.Member;
62        }
63
64        public void InsertMember(Member member)
65        {
66            this.ObjectContext.AddToMember(member);
67        }
68
69        public void UpdateMember(Member currentMember)
70        {
71            if ((currentMember.EntityState == EntityState.Detached))
72            {
73                this.ObjectContext.AttachAsModified(currentMember, this.ChangeSet.GetOriginal(currentMember));
74            }
75        }
76
77        public void DeleteMember(Member member)
78        {
79            if ((member.EntityState == EntityState.Detached))
80            {
81                this.ObjectContext.Attach(member);
82            }
83            this.ObjectContext.DeleteObject(member);
84        }
85
86        // TODO: Consider
87        // 1. Adding parameters to this method and constraining returned results, and/or
88        // 2. Adding query methods taking different parameters.
89        public IQueryable<Project> GetProject()
90        {
91            return this.ObjectContext.Project;
92        }
93    }
94}
95
96