Пример #1
0
 public void DeleteCustomPaycheck(CustomPaycheck custompaycheck)
 {
     if (custompaycheck == null)
     {
         throw new ArgumentException("custompaycheck is null.");
     }
     this.context.AddUpdateDeleteCustomPaycheck(null, null, custompaycheck);
 }
Пример #2
0
        public CustomPaycheck GetCustomPaycheck(int id)
        {
            CustomPaycheck item = null;

            using (var context = new PBEntities())
            {
                item = context.CustomPaychecks.Where(s => s.Id == id).FirstOrDefault();
            }
            return(item);
        }
Пример #3
0
 public HttpResponseMessage UpdateCustomPaycheck(CustomPaycheck custompaycheck)
 {
     if (custompaycheck == null)
     {
         throw new ArgumentException("custompaycheck is null.");
     }
     if (ModelState.IsValid)
     {
         this.context.AddUpdateDeleteCustomPaycheck(null, null, custompaycheck);
         return(Request.CreateResponse(HttpStatusCode.OK));
     }
     else
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
     }
 }
Пример #4
0
        public HttpResponseMessage CreateCustomPaycheck(CustomPaycheck custompaycheck)
        {
            CustomPaycheck tempItem = new CustomPaycheck();

            if (custompaycheck == null)
            {
                throw new ArgumentException("custompaycheck is null.");
            }

            if (ModelState.IsValid)
            {
                tempItem = this.context.AddUpdateDeleteCustomPaycheck(custompaycheck, null, null);
                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, tempItem);
                response.Headers.Location = new Uri(this.Request.RequestUri.AbsoluteUri + "/" + tempItem.Id);
                return(response);
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
        }
Пример #5
0
        public CustomPaycheck AddUpdateDeleteCustomPaycheck(CustomPaycheck AddItem, CustomPaycheck UpdateItem, CustomPaycheck DeleteItem)
        {
            if (AddItem != null)
            {
                CustomPaycheck newItem = this.uow.CustomPaycheckRepository.Insert(AddItem);
                this.uow.Save();
                return(newItem);
            }

            if (UpdateItem != null)
            {
                this.uow.CustomPaycheckRepository.Update(UpdateItem);
            }

            if (DeleteItem != null)
            {
                this.uow.CustomPaycheckRepository.Delete(DeleteItem);
            }

            this.uow.Save();

            return(null);
        }