示例#1
0
 public IHttpActionResult Put(int id, [FromBody] DAO.Service service)
 {
     try
     {
         if (service == null)
         {
             return(BadRequest());
         }
         //map
         var ad     = _serviceFactory.CreateService(service);
         var result = _repository.UpdateService(ad);
         if (result.Status == BookingRepositoryActionStatus.Updated)
         {
             // map to dao
             var updateService = _serviceFactory.CreateService(result.Entity);
             return(Ok(updateService));
         }
         else if (result.Status == BookingRepositoryActionStatus.NotFound)
         {
             return(NotFound());
         }
         return(BadRequest());
     }
     catch (Exception)
     {
         return(InternalServerError());
     }
 }
示例#2
0
        public Service CreateService(DAO.Service service)
        {
            return(new Service()
            {
                Id = service.Id,
                ServiceType = service.ServiceType,
                StartTime = service.StartTime,
                EndTime = service.EndTime,
                ServiceDate = service.ServiceDate,
                EmpId = service.EmpId,
                Description = service.Description,
                ServiceDuration = service.ServiceDuration,
                Price = service.Price,
                BusinessId = service.BusinessId

                             //BookingCancelations = service.BookingCancelations == null ? new List<BookingCancelation>() : service.BookingCancelations.Select( c => bookingCancelationFactory.CreateBookingCancelation(c)).ToList(),
                             //Payments = service.Payments == null ? new List<Payment>() : service.Payments.Select( p => paymentFactory.CreatePayment(p)).ToList()
            });
        }
示例#3
0
        public IHttpActionResult Post([FromBody] DAO.Service service)
        {
            try
            {
                if (service == null)
                {
                    return(BadRequest());
                }

                var b      = _serviceFactory.CreateService(service);
                var result = _repository.InsertService(b);
                if (result.Status == BookingRepositoryActionStatus.Created)
                {
                    var newService = _serviceFactory.CreateService(result.Entity);
                    return(Created(Request.RequestUri + "/" + newService.Id.ToString(), newService));
                }
                return(BadRequest());
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }
示例#4
0
        private void Save(string type)
        {
            if (Validate())
            {
                #region Insert SanPham

                if (_id != 0)
                {
                    ServiceDAO.Find(_id).Name = txtSystem.Text;
                    if (LocalizedPropertyDAO.Find(_id, 1, "Service", "Title") != null)
                    {
                        LocalizedPropertyDAO.Find(_id, 1, "Service", "Title").LocaleValue = txten.Text;
                    }
                    if (LocalizedPropertyDAO.Find(_id, 2, "Service", "Title") != null)
                    {
                        LocalizedPropertyDAO.Find(_id, 2, "Service", "Title").LocaleValue = txtjp.Text;
                    }
                    if (LocalizedPropertyDAO.Find(_id, 3, "Service", "Title") != null)
                    {
                        LocalizedPropertyDAO.Find(_id, 3, "Service", "Title").LocaleValue = txtvi.Text;
                    }
                    if (LocalizedPropertyDAO.Find(_id, 1, "Service", "Body") != null)
                    {
                        LocalizedPropertyDAO.Find(_id, 1, "Service", "Body").LocaleValue = ckFullen.Text;
                    }
                    if (LocalizedPropertyDAO.Find(_id, 2, "Service", "Body") != null)
                    {
                        LocalizedPropertyDAO.Find(_id, 2, "Service", "Body").LocaleValue = ckFulljp.Text;
                    }
                    if (LocalizedPropertyDAO.Find(_id, 3, "Service", "Body") != null)
                    {
                        LocalizedPropertyDAO.Find(_id, 3, "Service", "Body").LocaleValue = ckFullvi.Text;
                    }
                    ArticleDAO.Update();
                }
                else
                {
                    var x = new DAO.Service
                    {
                        Name = txtSystem.Text
                    };
                    ServiceDAO.Insert(x);
                    LocalizedPropertyDAO.Insert(new LocalizedProperty
                    {
                        EntityId       = x.Id,
                        LanguageId     = 1,
                        LocaleKeyGroup = "Service",
                        LocaleKey      = "Title",
                        LocaleValue    = txten.Text
                    });
                    LocalizedPropertyDAO.Insert(new LocalizedProperty
                    {
                        EntityId       = x.Id,
                        LanguageId     = 2,
                        LocaleKeyGroup = "Service",
                        LocaleKey      = "Title",
                        LocaleValue    = txtjp.Text
                    });
                    LocalizedPropertyDAO.Insert(new LocalizedProperty
                    {
                        EntityId       = x.Id,
                        LanguageId     = 3,
                        LocaleKeyGroup = "Service",
                        LocaleKey      = "Title",
                        LocaleValue    = txtvi.Text
                    });
                    LocalizedPropertyDAO.Insert(new LocalizedProperty
                    {
                        EntityId       = x.Id,
                        LanguageId     = 1,
                        LocaleKeyGroup = "Service",
                        LocaleKey      = "Body",
                        LocaleValue    = ckFullen.Text
                    });
                    LocalizedPropertyDAO.Insert(new LocalizedProperty
                    {
                        EntityId       = x.Id,
                        LanguageId     = 2,
                        LocaleKeyGroup = "Service",
                        LocaleKey      = "Body",
                        LocaleValue    = ckFulljp.Text
                    });
                    LocalizedPropertyDAO.Insert(new LocalizedProperty
                    {
                        EntityId       = x.Id,
                        LanguageId     = 3,
                        LocaleKeyGroup = "Service",
                        LocaleKey      = "Body",
                        LocaleValue    = ckFullvi.Text
                    });
                }

                #endregion

                if (type == "Publish")
                {
                    Response.Redirect("/AppAdmin/Service/Index.aspx");
                }
                else if (type == "Save")
                {
                    Response.Redirect("/AppAdmin/Service/Index.aspx");
                }
            }
            else
            {
                iRightAccess.Visible = false;
                ObjControl.LoadMyControl(idNotPermissionAccess, NotPermissControl);
            }
        }