public IActionResult EditView(int id) { var ownerEquity = _work.OwnerEquity.Get(id); OwnerEquityViewModel owners = new OwnerEquityViewModel(); owners.Id = ownerEquity.Id; owners.OwnerName = ownerEquity.OwnerName; owners.Department = ownerEquity.Department; owners.Designattion = ownerEquity.Designattion; owners.OwnerAddress = ownerEquity.OwnerAddress; owners.Email = ownerEquity.Email; owners.NIDNumber = ownerEquity.NIDNumber; owners.Mobile = ownerEquity.Mobile; owners.BirthDate = ownerEquity.BirthDate; owners.HasCommission = ownerEquity.HasCommission; return(PartialView("_Edit", owners)); }
public IActionResult Create(OwnerEquityViewModel ownerEquity) { if (ModelState.IsValid) { OwnersEquity owners = new OwnersEquity() { OwnerName = ownerEquity.OwnerName, Department = ownerEquity.Department, Designattion = ownerEquity.Designattion, OwnerAddress = ownerEquity.OwnerAddress, Email = ownerEquity.Email, NIDNumber = ownerEquity.NIDNumber, Mobile = ownerEquity.Mobile, BirthDate = ownerEquity.BirthDate, HasCommission = ownerEquity.HasCommission, }; if (ownerEquity.Photo != null) { var fileName = ContentDispositionHeaderValue.Parse(ownerEquity.Photo.ContentDisposition).FileName.Trim('"').Replace(" ", string.Empty); var path = _imagePath.GetImagePath(fileName, "OwnersEquities", ownerEquity.OwnerName); using (var stream = new FileStream(path, FileMode.Create)) { ownerEquity.Photo.CopyTo(stream); } owners.Photo = _imagePath.GetImagePathForDb(path); } _work.OwnerEquity.Add(owners); bool isSaved = _work.Save() > 0; if (isSaved) { return(Json(true)); } } return(Json(false)); }
public IActionResult Edit(OwnerEquityViewModel ownerEquity) { var owner = _work.OwnerEquity.Get(ownerEquity.Id); if (ModelState.IsValid) { owner.OwnerName = ownerEquity.OwnerName; owner.Department = ownerEquity.Department; owner.Designattion = ownerEquity.Designattion; owner.OwnerAddress = ownerEquity.OwnerAddress; owner.Email = ownerEquity.Email; owner.NIDNumber = ownerEquity.NIDNumber; owner.Mobile = ownerEquity.Mobile; owner.BirthDate = ownerEquity.BirthDate; owner.HasCommission = ownerEquity.HasCommission; if (ownerEquity.Photo != null) { var fileName = ContentDispositionHeaderValue.Parse(ownerEquity.Photo.ContentDisposition).FileName.Trim('"').Replace(" ", string.Empty); var path = _imagePath.GetImagePath(fileName, "OwnersEquities", ownerEquity.OwnerName); using (var stream = new FileStream(path, FileMode.Create)) { ownerEquity.Photo.CopyTo(stream); } owner.Photo = _imagePath.GetImagePathForDb(path); } _work.OwnerEquity.Update(owner); bool isUpdate = _work.Save() > 0; if (isUpdate) { return(Json(true)); } } return(Json(false)); }
public IActionResult CreateView() { OwnerEquityViewModel ownerEquity = new OwnerEquityViewModel(); return(PartialView("CreateView", ownerEquity)); }