public StaffCost UpdateStaffCost(StaffCost staffCost)
        {
            return(ExecuteFaultHandledOperation(() =>
            {
                var groupNames = new List <string>()
                {
                    BudgetModuleDefinition.GROUP_ADMINISTRATOR, BudgetModuleDefinition.GROUP_BUSINESS
                };
                AllowAccessToOperation(BudgetModuleDefinition.SOLUTION_NAME, groupNames);

                IStaffCostRepository staffCostRepository = _DataRepositoryFactory.GetDataRepository <IStaffCostRepository>();

                StaffCost updatedEntity = null;

                if (staffCost.StaffCostId == 0)
                {
                    updatedEntity = staffCostRepository.Add(staffCost);
                }
                else
                {
                    updatedEntity = staffCostRepository.Update(staffCost);
                }

                return updatedEntity;
            }));
        }
        public HttpResponseMessage UpdateStaffCost(HttpRequestMessage request, [FromBody] StaffCost staffCostModel)
        {
            return(GetHttpResponse(request, () =>
            {
                var staffCost = _MPROPEXService.UpdateStaffCost(staffCostModel);

                return request.CreateResponse <StaffCost>(HttpStatusCode.OK, staffCost);
            }));
        }
        public HttpResponseMessage GetStaffCost(HttpRequestMessage request, int staffCostId)
        {
            return(GetHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;

                StaffCost staffCost = _MPROPEXService.GetStaffCost(staffCostId);

                // notice no need to create a seperate model object since StaffCost entity will do just fine
                response = request.CreateResponse <StaffCost>(HttpStatusCode.OK, staffCost);

                return response;
            }));
        }
        public StaffCost GetStaffCost(int staffCostId)
        {
            return(ExecuteFaultHandledOperation(() =>
            {
                var groupNames = new List <string>()
                {
                    BudgetModuleDefinition.GROUP_ADMINISTRATOR, BudgetModuleDefinition.GROUP_BUSINESS
                };
                AllowAccessToOperation(BudgetModuleDefinition.SOLUTION_NAME, groupNames);

                IStaffCostRepository staffCostRepository = _DataRepositoryFactory.GetDataRepository <IStaffCostRepository>();

                StaffCost staffCostEntity = staffCostRepository.Get(staffCostId);
                if (staffCostEntity == null)
                {
                    NotFoundException ex = new NotFoundException(string.Format("StaffCost with ID of {0} is not in database", staffCostId));
                    throw new FaultException <NotFoundException>(ex, ex.Message);
                }

                return staffCostEntity;
            }));
        }
        public HttpResponseMessage DeleteStaffCost(HttpRequestMessage request, [FromBody] int staffCostId)
        {
            return(GetHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;

                // not that calling the WCF service here will authenticate access to the data
                StaffCost staffCost = _MPROPEXService.GetStaffCost(staffCostId);

                if (staffCost != null)
                {
                    _MPROPEXService.DeleteStaffCost(staffCostId);

                    response = request.CreateResponse(HttpStatusCode.OK);
                }
                else
                {
                    response = request.CreateErrorResponse(HttpStatusCode.NotFound, "No staffCost found under that ID.");
                }

                return response;
            }));
        }
Beispiel #6
0
 public StaffCost UpdateStaffCost(StaffCost staffCost)
 {
     return(Channel.UpdateStaffCost(staffCost));
 }