public CampanyViewModel GetCampany(int id) { Campany company = dbContext.Campanies.Include(x => x.Address).SingleOrDefault(x => x.Id == id); var companyViewModel = mapper.Map <Campany, CampanyViewModel>(company); return(companyViewModel); }
public void DeleteCampany(int id) { Campany company = dbContext.Campanies.Find(id); dbContext.Campanies.Remove(company); dbContext.SaveChanges(); }
public void AddCampany(CampanyDto dto) { Campany company = mapper.Map <CampanyDto, Campany>(dto); dbContext.Campanies.Add(company); dbContext.SaveChanges(); }
public void EditCampany(CampanyDto dto) { Campany myCampany = dbContext.Campanies.Include(x => x.Address).SingleOrDefault(x => x.Id == dto.Id); Campany company = mapper.Map <CampanyDto, Campany>(dto, myCampany); dbContext.Campanies.Update(company); dbContext.SaveChanges(); }
public ActionResult AddCompany(Campany campany) { CampanyRepository blCompany = new CampanyRepository(); if (ModelState.IsValid) { if (blCompany.Add(campany)) { return(JavaScript("alert('با موفقیت ثبت شد')")); } else { return(JavaScript("alert('ثبت نشد')")); } } else { return(JavaScript("alert('مقادیر ورودی اشتباه است')")); } }