public void DeleteServices(ServicesDTO entity) { var service = servicesRepository.GetAll().Where(x => x.ServiceId == entity.ServiceId).FirstOrDefault(); service.ServiceTitle = entity.ServiceTitle; service.ServiceDescription = entity.ServiceDescription; service.Photo = entity.Photo; servicesRepository.Delete(service); }
public void AddNewServices(ServicesDTO entity) { Service service = new Service { ServiceTitle = entity.ServiceTitle, ServiceDescription = entity.ServiceDescription, Photo = entity.Photo }; servicesRepository.Add(service); }
private void txtsl_TextChanged(object sender, EventArgs e) { if (txtsl.Text != "") { int sl; int gia; sl = Convert.ToInt32(txtsl.Text); ServicesDTO transfer = new ServicesDTO(cbxmadv.Text); gia = Convert.ToInt32(ServicesDAO.Instance.getServicePrice(transfer)); txttong.Text = (sl * gia).ToString(); } }
void addService(string mapd, string madv, int sl, int tien) { ServicesDTO transfer = new ServicesDTO(mapd, madv, sl, tien); if (ServicesDAO.Instance.addService(transfer) >= 1) { MessageBox.Show("Đã thêm dịch vụ"); loadListServices(); } else { MessageBox.Show("Lỗi ! Không thêm được dịch vụ"); } }
public async Task <ActionResult> Edit(ServicesDTO services, HttpPostedFileBase file) { if (!ModelState.IsValid) { ModelState.AddModelError(" ", "duzgun yazilmayib metin !!!!"); return(View(services)); } int id = services.Id; ServicesDTO dto = await db.Services.FirstOrDefaultAsync(x => x.Id == id); dto.ServicesTitle = services.ServicesTitle; dto.ServicesContent = services.ServicesContent; await db.SaveChangesAsync(); #region imageUpload if (file != null && file.ContentLength > 0) { // Get extension string ext = file.ContentType.ToLower(); // Verify extension if (ext != "image/jpg" && ext != "image/jpeg" && ext != "image/pjpeg" && ext != "image/gif" && ext != "image/x-png" && ext != "image/png") { ModelState.AddModelError("", "The image was not uploaded - wrong image extension."); return(View(services)); } // Set uplpad directory paths var originalDirectory = new DirectoryInfo(string.Format("{0}Content\\img", Server.MapPath(@"\"))); var pathString1 = Path.Combine(originalDirectory.ToString(), "service\\" + id.ToString()); var pathString2 = Path.Combine(originalDirectory.ToString(), "service\\" + id.ToString() + "\\thumbs"); if (!Directory.Exists(pathString1)) { Directory.CreateDirectory(pathString1); } if (!Directory.Exists(pathString2)) { Directory.CreateDirectory(pathString2); } // Delete files from directories DirectoryInfo di1 = new DirectoryInfo(pathString1); DirectoryInfo di2 = new DirectoryInfo(pathString2); foreach (FileInfo file2 in di1.GetFiles()) { file2.Delete(); } foreach (FileInfo file3 in di2.GetFiles()) { file3.Delete(); } if (di1.GetFiles() == null) { ModelState.AddModelError("Image", "Sekilin yolu movcud deyil"); } // Save image name string imageName = file.FileName; ServicesDTO dtoBase = await db.Services.FindAsync(id); dtoBase.Image = imageName; await db.SaveChangesAsync(); // Save original and thumb images var path = string.Format("{0}\\{1}", pathString1, imageName); var path2 = string.Format("{0}\\{1}", pathString2, imageName); file.SaveAs(path); WebImage img = new WebImage(file.InputStream); img.Resize(200, 200); img.Save(path2); } #endregion TempData["SM"] = "You have edited the home page!"; return(RedirectToAction("Index")); }
public int addService(ServicesDTO transfer) { object[] parameters = new object[] { transfer.Mapd, transfer.Madv, transfer.Sl, transfer.Tien }; return(DataProvider.Instance.ExecuteNonQuery("insertService @mapd , @madv , @sl , @tien", parameters)); }
public string getServicePrice(ServicesDTO transfer) { object[] paremeters = new object[] { transfer.Madv }; return(DataProvider.Instance.ExecuteQuery("getServicePrice @madv", paremeters).Rows[0][0].ToString()); }
public IActionResult UpdateHizmet(ServicesDTO entity) { services.UpdateServices(entity); return(Redirect("/Hizmetler")); }
public IActionResult AddNewHizmet(ServicesDTO entity) { services.AddNewServices(entity); return(Redirect("/Hizmetler")); }