// Service: Admin/Service/Edit/id public virtual ActionResult Edit(int id, ServiceEdit postEdit) { if (!ModelState.IsValid) { postEdit.TagList = _tagService.DropDownList(postEdit.TagIds); postEdit.CategoryList = _serviceCategoryService.DropDownList(postEdit.CategoryIds); return(View(postEdit)); } HttpPostedFileBase file = Request.Files["user-avatar"]; if (string.IsNullOrEmpty(file.FileName)) { var post = _serviceService.Find(id); postEdit.TitleImg = post.TitleImg; } else { var path = Path.Combine(Server.MapPath("~/Content/upload/images/"), file.FileName); file.SaveAs(path); postEdit.TitleImg = file.FileName; } _serviceService.Update(postEdit, id); _uow.SaveAllChanges(); return(RedirectToAction("Index"));; }
public ActionResult Edit(int id, ServiceEdit model) { if (ModelState.IsValid) { var service = CreateServiceService(); service.UpdateService(model); return(RedirectToAction("Index")); } return(View(model)); }
public bool UpdateService(ServiceEdit model) { var entity = _context.Services.Find(model.ServiceId); entity.Name = model.Name; entity.Cost = model.Cost; entity.Duration = model.Duration; entity.DurationUnit = model.DurationUnit; entity.Description = model.Description; return(_context.SaveChanges() == 1); }
/// <summary> /// Вызывается при нажатии на пункт меню "Изменить" в таблице "Расходы на обслуживание" /// </summary> private void ServiceChangeItem_Click(object sender, EventArgs e) { if (_selectedService == null) { return; } var changeForm = new ServiceEdit(_selectedService); changeForm.FormClosed += ChangeForm_FormClosed; changeForm.Show(); Enabled = false; }
public bool UpdateService(ServiceEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx.Services.Single(e => e.ServiceId == model.ServiceId && e.ServiceOwnerId == _sUserId); entity.ServiceName = model.ServiceName; entity.ServicePrice = model.ServicePrice; entity.ServiceDescription = model.ServiceDescription; entity.ModifiedUtc = DateTimeOffset.UtcNow; entity.ServiceReviewId = model.ServiceReviewId; return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Put(ServiceEdit servicez) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateServiceService(); if (!service.UpdateService(servicez)) { return(InternalServerError()); } return(Ok()); }
// GET: Admin/Service/Edit public virtual ActionResult Edit(int?id) { if (id == 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ServiceEdit post = _serviceService.FindForEdit(id ?? 0); post.TagList = _tagService.DropDownList(post.TagIds); post.CategoryList = _serviceCategoryService.DropDownList(post.CategoryIds); if (post == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } return(View(post)); }
// GET: Service/Edit public ActionResult Edit(int id) { var service = CreateServiceService(); var detail = service.GetServiceById(id); var model = new ServiceEdit { ServiceId = detail.ServiceId, Name = detail.Name, Cost = detail.Cost, Duration = detail.Duration, DurationUnit = detail.DurationUnit, Description = detail.Description }; return(View(model)); }
public void Update(ServiceEdit post, int id) { Service selectedpost = _service.Find(id); foreach (var item in selectedpost.Tags.Where(x => !post.TagIds.Contains(x.Id)).ToList()) { selectedpost.Tags.Remove(item); } foreach (var item in post.TagIds) { selectedpost.Tags.Add(_tags.Find(item)); } foreach (var item in selectedpost.ServiceCategories.Where(x => !post.CategoryIds.Contains(x.Id)).ToList()) { selectedpost.ServiceCategories.Remove(item); } foreach (var item in post.CategoryIds) { selectedpost.ServiceCategories.Add(_serviceCategory.Find(item)); } selectedpost.CreatedDate = DateTime.Now; selectedpost.ImageTitle = post.TitleImg; selectedpost.Title = post.Title; selectedpost.TitleEn = post.TitleEn; selectedpost.TitleAr = post.TitleAr; selectedpost.TitleRu = post.TitleRu; selectedpost.Body = post.Body; selectedpost.BodyEn = post.BodyEn; selectedpost.BodyAr = post.BodyAr; selectedpost.BodyRu = post.BodyRu; selectedpost.Slug = post.Slug; selectedpost.Keyword = post.Keyword; selectedpost.Description = post.Description; selectedpost.DescriptionEn = post.DescriptionEn; selectedpost.DescriptionAr = post.DescriptionAr; selectedpost.DescriptionRu = post.DescriptionRu; }
private void btnEdit_Click(object sender, EventArgs e) { if (txtId.Text == string.Empty) { MessageBox.Show("You don't choose a service to edit!", "Infomations", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Service rt = new Service() { Id = txtId.Text, Name = txtName.Text, Price = decimal.Parse(txtPrice.Text.Trim()), Unit = txtUnit.Text.Trim() }; ServiceEdit ServiceEdit = new ServiceEdit(rt); ServiceEdit.EditCompletedHandler += FormServiceEdit_Completed; ServiceEdit.ShowDialog(); } }
private void btnAdd_Click(object sender, EventArgs e) { ServiceEdit ServiceEdit = new ServiceEdit(); ServiceEdit.EditCompletedHandler += FormServiceEdit_Completed; ServiceEdit.ShowDialog(); }