public JsonResult UpdateEmployeeInformation(HttpPostedFileBase file, VM_EmployeeInformation aEmployee) { tblEmployeeInformation employeeInformation = unitOfWork.EmployeeInformationRepository.GetByID(aEmployee.EmployeeId); string path = ""; if (file != null) { string pic = System.IO.Path.GetFileName(file.FileName); path = System.IO.Path.Combine( Server.MapPath("~/Image"), pic); // file is uploaded file.SaveAs(path); employeeInformation.EmployeeId = aEmployee.EmployeeId; employeeInformation.EmployeeName = aEmployee.EmployeeName; employeeInformation.EmployeeAddress = aEmployee.EmployeeAddress; employeeInformation.ContactNumber = aEmployee.ContactNumber; employeeInformation.EmployeeNid = aEmployee.EmployeeNid; employeeInformation.EmployeeEmail = aEmployee.EmployeeEmail; employeeInformation.EmployeeImage = "/Image/" + pic; employeeInformation.DesignationId = aEmployee.DesignationId; employeeInformation.EditedBy = SessionManger.LoggedInUser(Session); employeeInformation.EditedDateTime = DateTime.Now; } else { employeeInformation.EmployeeId = aEmployee.EmployeeId; employeeInformation.EmployeeName = aEmployee.EmployeeName; employeeInformation.EmployeeAddress = aEmployee.EmployeeAddress; employeeInformation.ContactNumber = aEmployee.ContactNumber; employeeInformation.EmployeeNid = aEmployee.EmployeeNid; employeeInformation.EmployeeEmail = aEmployee.EmployeeEmail; employeeInformation.EmployeeImage = employeeInformation.EmployeeImage; employeeInformation.DesignationId = aEmployee.DesignationId; employeeInformation.EditedBy = SessionManger.LoggedInUser(Session); employeeInformation.EditedDateTime = DateTime.Now; } var EmailExist = unitOfWork.EmployeeInformationRepository.Get() .Where(a => a.EmployeeEmail == aEmployee.EmployeeEmail && a.EmployeeId != aEmployee.EmployeeId && a.EmployeeEmail != "undefined" && !string.IsNullOrEmpty(a.EmployeeEmail)).ToList(); try { if (!EmailExist.Any()) { unitOfWork.EmployeeInformationRepository.Update(employeeInformation); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Successfully Edited" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, errorMessage = "This Email already exist." }, JsonRequestBehavior.AllowGet)); } } catch (Exception exception) { return(Json(new { success = false, errorMessage = exception.Message }, JsonRequestBehavior.AllowGet)); } }
public JsonResult UpdateGroupAndShiftMapping(VM_GroupAndShiftMapping groupAndShiftMapping) { try { tblGroupAndShiftMapping bGroupAndShiftMapping = unitOfWork.GroupAndShiftMappingRepository.GetByID(groupAndShiftMapping.GroupMappingId); if (bGroupAndShiftMapping == null) { return(Json(new { success = false, errorMessage = "Edit Failed" }, JsonRequestBehavior.AllowGet)); } else { if (groupAndShiftMapping.ShiftId == 1) { if (groupAndShiftMapping.GroupId == 1) { tblGroupAndShiftMapping aGroupAndShiftMapping = unitOfWork.GroupAndShiftMappingRepository.GetByID(groupAndShiftMapping.GroupMappingId); aGroupAndShiftMapping.GroupMappingId = groupAndShiftMapping.GroupMappingId; //aGroupAndShiftMapping.TransferDate = groupAndShiftMapping.TransferDate; aGroupAndShiftMapping.Day = "A"; aGroupAndShiftMapping.Night = "B"; aGroupAndShiftMapping.EditedBy = SessionManger.LoggedInUser(Session); aGroupAndShiftMapping.EditedDateTime = DateTime.Now; unitOfWork.GroupAndShiftMappingRepository.Update(aGroupAndShiftMapping); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Group and Shift Mapping edited successfully" }, JsonRequestBehavior.AllowGet)); } else { tblGroupAndShiftMapping aGroupAndShiftMapping = unitOfWork.GroupAndShiftMappingRepository.GetByID(groupAndShiftMapping.GroupMappingId); aGroupAndShiftMapping.GroupMappingId = groupAndShiftMapping.GroupMappingId; //aGroupAndShiftMapping.TransferDate = groupAndShiftMapping.TransferDate; aGroupAndShiftMapping.Day = "B"; aGroupAndShiftMapping.Night = "A"; aGroupAndShiftMapping.EditedBy = SessionManger.LoggedInUser(Session); aGroupAndShiftMapping.EditedDateTime = DateTime.Now; unitOfWork.GroupAndShiftMappingRepository.Update(aGroupAndShiftMapping); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Group and Shift Mapping edited successfully" }, JsonRequestBehavior.AllowGet)); } } else { if (groupAndShiftMapping.GroupId == 1) { tblGroupAndShiftMapping aGroupAndShiftMapping = unitOfWork.GroupAndShiftMappingRepository.GetByID(groupAndShiftMapping.GroupMappingId); aGroupAndShiftMapping.GroupMappingId = groupAndShiftMapping.GroupMappingId; //aGroupAndShiftMapping.TransferDate = groupAndShiftMapping.TransferDate; aGroupAndShiftMapping.Day = "B"; aGroupAndShiftMapping.Night = "A"; aGroupAndShiftMapping.EditedBy = SessionManger.LoggedInUser(Session); aGroupAndShiftMapping.EditedDateTime = DateTime.Now; unitOfWork.GroupAndShiftMappingRepository.Update(aGroupAndShiftMapping); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Group and Shift Mapping edited successfully" }, JsonRequestBehavior.AllowGet)); } else { tblGroupAndShiftMapping aGroupAndShiftMapping = unitOfWork.GroupAndShiftMappingRepository.GetByID(groupAndShiftMapping.GroupMappingId); aGroupAndShiftMapping.GroupMappingId = groupAndShiftMapping.GroupMappingId; //aGroupAndShiftMapping.TransferDate = groupAndShiftMapping.TransferDate; aGroupAndShiftMapping.Day = "A"; aGroupAndShiftMapping.Night = "B"; aGroupAndShiftMapping.EditedBy = SessionManger.LoggedInUser(Session); aGroupAndShiftMapping.EditedDateTime = DateTime.Now; unitOfWork.GroupAndShiftMappingRepository.Update(aGroupAndShiftMapping); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Group and Shift Mapping edited successfully" }, JsonRequestBehavior.AllowGet)); } } } } catch (Exception exception) { return(Json(new { success = false, errorMessage = exception.Message }, JsonRequestBehavior.AllowGet)); } }
public JsonResult AddGroupAndShiftMapping(VM_GroupAndShiftMapping groupAndShiftMapping, DateTime fromDate) { if (ModelState.IsValid) { try { var date = DateTime.Parse(fromDate.ToString()); var dateInfo = string.Format("{0:yyyy-MM-dd}", date); var inputDbDate = unitOfWork.GroupAndShiftMappingRepository.Get().Where(a => a.TransferDate.Value.Date == Convert.ToDateTime(dateInfo)).Select(x => x.TransferDate).ToList(); if (!inputDbDate.Any()) { if (groupAndShiftMapping.ShiftId == 1) { if (groupAndShiftMapping.GroupId == 1) { tblGroupAndShiftMapping aGroupAndShiftMapping = new tblGroupAndShiftMapping(); aGroupAndShiftMapping.TransferDate = fromDate; aGroupAndShiftMapping.Day = "A"; aGroupAndShiftMapping.Night = "B"; aGroupAndShiftMapping.RestaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); aGroupAndShiftMapping.CreatedBy = SessionManger.LoggedInUser(Session); aGroupAndShiftMapping.CreatedDateTime = DateTime.Now; aGroupAndShiftMapping.EditedBy = null; aGroupAndShiftMapping.EditedDateTime = null; unitOfWork.GroupAndShiftMappingRepository.Insert(aGroupAndShiftMapping); unitOfWork.Save(); return (Json(new { success = true, successMessage = "Group and Shift Mapping successfully" }, JsonRequestBehavior.AllowGet)); } else { tblGroupAndShiftMapping aGroupAndShiftMapping = new tblGroupAndShiftMapping(); aGroupAndShiftMapping.TransferDate = fromDate; aGroupAndShiftMapping.Day = "B"; aGroupAndShiftMapping.Night = "A"; aGroupAndShiftMapping.RestaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); aGroupAndShiftMapping.CreatedBy = SessionManger.LoggedInUser(Session); aGroupAndShiftMapping.CreatedDateTime = DateTime.Now; aGroupAndShiftMapping.EditedBy = null; aGroupAndShiftMapping.EditedDateTime = null; unitOfWork.GroupAndShiftMappingRepository.Insert(aGroupAndShiftMapping); unitOfWork.Save(); return (Json(new { success = true, successMessage = "Group and Shift Mapping successfully" }, JsonRequestBehavior.AllowGet)); } } else { if (groupAndShiftMapping.GroupId == 1) { tblGroupAndShiftMapping aGroupAndShiftMapping = new tblGroupAndShiftMapping(); aGroupAndShiftMapping.TransferDate = fromDate; aGroupAndShiftMapping.Day = "B"; aGroupAndShiftMapping.Night = "A"; aGroupAndShiftMapping.RestaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); aGroupAndShiftMapping.CreatedBy = SessionManger.LoggedInUser(Session); aGroupAndShiftMapping.CreatedDateTime = DateTime.Now; aGroupAndShiftMapping.EditedBy = null; aGroupAndShiftMapping.EditedDateTime = null; unitOfWork.GroupAndShiftMappingRepository.Insert(aGroupAndShiftMapping); unitOfWork.Save(); return (Json(new { success = true, successMessage = "Group and Shift Mapping successfully" }, JsonRequestBehavior.AllowGet)); } else { tblGroupAndShiftMapping aGroupAndShiftMapping = new tblGroupAndShiftMapping(); aGroupAndShiftMapping.TransferDate = fromDate; aGroupAndShiftMapping.Day = "A"; aGroupAndShiftMapping.Night = "B"; aGroupAndShiftMapping.RestaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); aGroupAndShiftMapping.CreatedBy = SessionManger.LoggedInUser(Session); aGroupAndShiftMapping.CreatedDateTime = DateTime.Now; aGroupAndShiftMapping.EditedBy = null; aGroupAndShiftMapping.EditedDateTime = null; unitOfWork.GroupAndShiftMappingRepository.Insert(aGroupAndShiftMapping); unitOfWork.Save(); return (Json(new { success = true, successMessage = "Group and Shift Mapping successfully" }, JsonRequestBehavior.AllowGet)); } } } else { return(Json(new { success = false, errorMessage = "Group and Shift Mapping Already done in this Date " }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Model is not Valid" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult SaveProductToStore(int SupplierId, int StoreId, List <VM_ProductToStore> productList) { try { foreach (VM_ProductToStore aProduct in productList) { tblProductTransfer aProductTransfer = new tblProductTransfer(); tblProductFromSupplier aProductFromSupplier = new tblProductFromSupplier(); aProductFromSupplier.StoreId = aProductTransfer.StoreId = StoreId; aProductFromSupplier.SupplierId = aProductTransfer.SupplierId = SupplierId; aProductFromSupplier.ProductId = aProductTransfer.ProductId = aProduct.ProductId; aProductFromSupplier.Quantity = aProductTransfer.Quantity = aProduct.Quantity; aProductFromSupplier.Unit = aProductTransfer.Unit = aProduct.Unit; aProductFromSupplier.UnitPrice = aProductTransfer.UnitPrice = (decimal?)aProduct.UnitPrice; aProductFromSupplier.isIn = aProductTransfer.isIn = true; aProductFromSupplier.isOut = aProductTransfer.isOut = false; aProductTransfer.TransferDate = DateTime.Now; //aProductFromSupplier = aProductTransfer.CreatedDateTime = DateTime.Now; aProductFromSupplier.DateTime = aProductTransfer.DateTime = DateTime.Now; aProductFromSupplier.RestaurantId = aProductTransfer.RestaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); aProductFromSupplier.CreatedBy = aProductTransfer.CreatedBy = SessionManger.LoggedInUser(Session); aProductFromSupplier.CreatedDateTime = aProductTransfer.CreatedDateTime = DateTime.Now; aProductFromSupplier.EditedBy = aProductTransfer.EditedBy = null; aProductFromSupplier.EditedDateTime = aProductTransfer.EditedDateTime = null; unitOfWork.ProductTransferRepository.Insert(aProductTransfer); unitOfWork.ProductFromSupplierRepository.Insert(aProductFromSupplier); } unitOfWork.Save(); SupplierProductToStoreReport(SupplierId, StoreId, productList); return(Json(new { success = true, successMessage = "Product Added Successfully" })); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public JsonResult OpeningProductBalanceInStore(int StoreId, List <VM_ProductToStore> productList, DateTime fromDate) { if (ModelState.IsValid) { try { if (unitOfWork.StoreRepository.GetByID(StoreId).is_mainStore == true) { foreach (VM_ProductToStore aProduct in productList) { tblProductTransfer aProductTransfer = new tblProductTransfer(); aProductTransfer.StoreId = StoreId; aProductTransfer.TransferDate = fromDate; aProductTransfer.SupplierId = null; aProductTransfer.ProductId = aProduct.ProductId; aProductTransfer.Quantity = (decimal?)aProduct.OpeningBalance; aProductTransfer.Unit = aProduct.Unit; aProductTransfer.UnitPrice = null; aProductTransfer.isIn = true; aProductTransfer.isOut = false; aProductTransfer.DateTime = DateTime.Now; aProductTransfer.RestaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); aProductTransfer.CreatedBy = SessionManger.LoggedInUser(Session); aProductTransfer.CreatedDateTime = DateTime.Now; aProductTransfer.EditedBy = null; aProductTransfer.EditedDateTime = null; unitOfWork.ProductTransferRepository.Insert(aProductTransfer); } unitOfWork.Save(); return(Json(new { success = true, successMessage = "Opening Product Balance Added Successfully" }, JsonRequestBehavior.AllowGet)); } if (unitOfWork.StoreRepository.GetByID(StoreId).isProductionHouseStore == true) { foreach (VM_ProductToStore aProduct in productList) { tblProductTransfer product1 = new tblProductTransfer(); product1.StoreId = StoreId; product1.TransferDate = fromDate; product1.ProductId = aProduct.ProductId; product1.Quantity = (decimal?)aProduct.OpeningBalance; product1.Unit = aProduct.Unit; product1.isIn = true; product1.isOut = false; product1.DateTime = DateTime.Now; product1.RestaurantId = int.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); product1.CreatedBy = SessionManger.LoggedInUser(Session); product1.CreatedDateTime = DateTime.Now; product1.EditedBy = null; product1.EditedDateTime = null; unitOfWork.ProductTransferRepository.Insert(product1); } unitOfWork.Save(); return(Json(new { success = true, successMessage = "Opening Product Balance Added Successfully" }, JsonRequestBehavior.AllowGet)); } if (unitOfWork.StoreRepository.GetByID(StoreId).IsSellsPointStore == true) { //var SellsPoint = unitOfWork.SellsPointRepository.Get().Where(x => x.SellsPointStoreId == StoreId).First(); foreach (VM_ProductToStore aProduct in productList) { //tblPHtoSPProductTransfer product = new tblPHtoSPProductTransfer(); //product.SellsPointId = SellsPoint.SellsPointId; //product.ProductionHouseId = null; //product.ProductId = aProduct.ProductId; //product.Quantity = (decimal?)aProduct.OpeningBalance; //product.Unit = aProduct.Unit; //product.isIn = true; //product.isOut = false; //product.RestaurantId = int.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); //product.CreatedBy = SessionManger.LoggedInUser(Session); //product.CreatedDateTime = DateTime.Now; //product.EditedBy = null; //product.EditedDateTime = null; //unitOfWork.PHToSPProductTransferRepository.Insert(product); //unitOfWork.Save(); tblProductTransfer product2 = new tblProductTransfer(); product2.StoreId = StoreId; product2.TransferDate = fromDate; product2.ProductId = aProduct.ProductId; product2.Quantity = (decimal?)aProduct.OpeningBalance; product2.Unit = aProduct.Unit; product2.isIn = true; product2.isOut = false; product2.DateTime = DateTime.Now; product2.RestaurantId = int.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); product2.CreatedBy = SessionManger.LoggedInUser(Session); product2.CreatedDateTime = DateTime.Now; product2.EditedBy = null; product2.EditedDateTime = null; unitOfWork.ProductTransferRepository.Insert(product2); } unitOfWork.Save(); return(Json(new { success = true, successMessage = "Opening Product Balance Added Successfully" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, errorMessage = "Opening Product Balance not Save" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Model is not Valid" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddPartsInBusRegistrationNoFromStore(string registrationNo, DateTime buyDate, int storeId, List <Vm_PartsTransfetToBusRegistrationNoFromStore> partsList) { if (ModelState.IsValid) { try { foreach (Vm_PartsTransfetToBusRegistrationNoFromStore addPartFromStore in partsList) { tblBuyPartsFromSupplier addPartsFromStore = new tblBuyPartsFromSupplier(); addPartsFromStore.RegistrationNo = registrationNo; addPartsFromStore.BuyDate = buyDate; addPartsFromStore.PartsId = addPartFromStore.PartsId; addPartsFromStore.SupplierId = null; addPartsFromStore.Quantity = addPartFromStore.Quantity; addPartsFromStore.UnitPrice = addPartFromStore.UnitPrice; addPartsFromStore.Other = null; addPartsFromStore.StoreId = storeId; addPartsFromStore.Price = addPartFromStore.Quantity * addPartFromStore.UnitPrice; addPartsFromStore.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); addPartsFromStore.CreatedBy = SessionManger.LoggedInUser(Session); addPartsFromStore.CreatedDateTime = DateTime.Now; addPartsFromStore.EditedBy = null; addPartsFromStore.EditedDateTime = null; unitOfWork.BuyPartsFromSupplierRepository.Insert(addPartsFromStore); unitOfWork.Save(); tblPartsTransfer aPartsTransfer = new tblPartsTransfer(); aPartsTransfer.StoreId = storeId; aPartsTransfer.Date = buyDate; aPartsTransfer.PartsId = addPartFromStore.PartsId; aPartsTransfer.Quantity = addPartFromStore.Quantity; aPartsTransfer.UnitPrice = addPartFromStore.UnitPrice; aPartsTransfer.Price = addPartFromStore.Quantity * addPartFromStore.UnitPrice; aPartsTransfer.isIn = false; aPartsTransfer.isOut = true; aPartsTransfer.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); aPartsTransfer.CreatedBy = SessionManger.LoggedInUser(Session); aPartsTransfer.CreatedDateTime = DateTime.Now; aPartsTransfer.EditedBy = null; aPartsTransfer.EditedDateTime = null; unitOfWork.PartsTransferRepository.Insert(aPartsTransfer); unitOfWork.Save(); } return(Json(new { success = true, successMessage = " Added Successfully!" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Model is not valid" }, JsonRequestBehavior.AllowGet)); } }
//public ActionResult AddPriceForPartsFromSupplier(string registrationNo, DateTime buyDate, IEnumerable<VM_BuyPartsFromSupplier> buyPartsFromSupplier, string other, int? price) //{ // if (ModelState.IsValid) // { // try // { // if (buyPartsFromSupplier==null) // { // tblBuyPartsFromSupplier bBuyPartsFromSupplier = new tblBuyPartsFromSupplier(); // bBuyPartsFromSupplier.RegistrationNo = registrationNo; // bBuyPartsFromSupplier.BuyDate = buyDate; // bBuyPartsFromSupplier.PartsId = null; // bBuyPartsFromSupplier.SupplierId = null; // bBuyPartsFromSupplier.Quantity = null; // bBuyPartsFromSupplier.UnitPrice = null; // bBuyPartsFromSupplier.Other = other; // bBuyPartsFromSupplier.Price = price; // bBuyPartsFromSupplier.WorkShopId = // Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); // bBuyPartsFromSupplier.CreatedBy = SessionManger.LoggedInUser(Session); // bBuyPartsFromSupplier.CreatedDateTime = DateTime.Now; // bBuyPartsFromSupplier.EditedBy = null; // bBuyPartsFromSupplier.EditedDateTime = null; // unitOfWork.BuyPartsFromSupplierRepository.Insert(bBuyPartsFromSupplier); // unitOfWork.Save(); // } // else // { // tblBuyPartsFromSupplier aBuyPartsFromSupplier = new tblBuyPartsFromSupplier(); // foreach (VM_BuyPartsFromSupplier buyPartsFromSuppliers in buyPartsFromSupplier) // { // aBuyPartsFromSupplier.RegistrationNo = registrationNo; // aBuyPartsFromSupplier.BuyDate = buyDate; // aBuyPartsFromSupplier.PartsId = buyPartsFromSuppliers.PartsId; // aBuyPartsFromSupplier.SupplierId = buyPartsFromSuppliers.SupplierId; // aBuyPartsFromSupplier.Quantity = buyPartsFromSuppliers.Quantity; // aBuyPartsFromSupplier.UnitPrice = buyPartsFromSuppliers.UnitPrice; // aBuyPartsFromSupplier.Other = null; // aBuyPartsFromSupplier.Price = buyPartsFromSuppliers.Price; // aBuyPartsFromSupplier.WorkShopId = // Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); // aBuyPartsFromSupplier.CreatedBy = SessionManger.LoggedInUser(Session); // aBuyPartsFromSupplier.CreatedDateTime = DateTime.Now; // aBuyPartsFromSupplier.EditedBy = null; // aBuyPartsFromSupplier.EditedDateTime = null; // unitOfWork.BuyPartsFromSupplierRepository.Insert(aBuyPartsFromSupplier); // unitOfWork.Save(); // } // if (other != null || price != null) // { // aBuyPartsFromSupplier.RegistrationNo = registrationNo; // aBuyPartsFromSupplier.BuyDate = buyDate; // aBuyPartsFromSupplier.PartsId = null; // aBuyPartsFromSupplier.SupplierId = null; // aBuyPartsFromSupplier.Quantity = null; // aBuyPartsFromSupplier.UnitPrice = null; // aBuyPartsFromSupplier.Other = other; // aBuyPartsFromSupplier.Price = price; // aBuyPartsFromSupplier.WorkShopId = // Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); // aBuyPartsFromSupplier.CreatedBy = SessionManger.LoggedInUser(Session); // aBuyPartsFromSupplier.CreatedDateTime = DateTime.Now; // aBuyPartsFromSupplier.EditedBy = null; // aBuyPartsFromSupplier.EditedDateTime = null; // unitOfWork.BuyPartsFromSupplierRepository.Insert(aBuyPartsFromSupplier); // unitOfWork.Save(); // } // } // return Json(new { success = true, successMessage = " Added Successfully!" }, JsonRequestBehavior.AllowGet); // } // catch (Exception ex) // { // return Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet); // } // } // else // { // return Json(new { success = false, errorMessage = "Model is not valid" }, JsonRequestBehavior.AllowGet); // } //} public ActionResult AddPriceForPartsFromSupplier(string registrationNo, DateTime buyDate, IEnumerable <VM_BuyPartsFromSupplier> buyPartsFromSupplier, IEnumerable <VM_BuyPartsFromSupplier> otherExpense) { if (ModelState.IsValid) { try { if (buyPartsFromSupplier == null) { tblBuyPartsFromSupplier bBuyPartsFromSupplier = new tblBuyPartsFromSupplier(); foreach (VM_BuyPartsFromSupplier otherExpenses in otherExpense) { bBuyPartsFromSupplier.RegistrationNo = registrationNo; bBuyPartsFromSupplier.BuyDate = buyDate; bBuyPartsFromSupplier.PartsId = null; bBuyPartsFromSupplier.SupplierId = null; bBuyPartsFromSupplier.Quantity = null; bBuyPartsFromSupplier.UnitPrice = null; bBuyPartsFromSupplier.Other = otherExpenses.Other; bBuyPartsFromSupplier.Price = otherExpenses.Price; bBuyPartsFromSupplier.StoreId = null; bBuyPartsFromSupplier.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); bBuyPartsFromSupplier.CreatedBy = SessionManger.LoggedInUser(Session); bBuyPartsFromSupplier.CreatedDateTime = DateTime.Now; bBuyPartsFromSupplier.EditedBy = null; bBuyPartsFromSupplier.EditedDateTime = null; unitOfWork.BuyPartsFromSupplierRepository.Insert(bBuyPartsFromSupplier); unitOfWork.Save(); } } else { tblBuyPartsFromSupplier aBuyPartsFromSupplier = new tblBuyPartsFromSupplier(); foreach (VM_BuyPartsFromSupplier buyPartsFromSuppliers in buyPartsFromSupplier) { aBuyPartsFromSupplier.RegistrationNo = registrationNo; aBuyPartsFromSupplier.BuyDate = buyDate; aBuyPartsFromSupplier.PartsId = buyPartsFromSuppliers.PartsId; aBuyPartsFromSupplier.SupplierId = buyPartsFromSuppliers.SupplierId; aBuyPartsFromSupplier.Quantity = buyPartsFromSuppliers.Quantity; aBuyPartsFromSupplier.UnitPrice = buyPartsFromSuppliers.UnitPrice; aBuyPartsFromSupplier.Other = null; aBuyPartsFromSupplier.StoreId = null; aBuyPartsFromSupplier.Price = buyPartsFromSuppliers.Quantity * buyPartsFromSuppliers.UnitPrice; aBuyPartsFromSupplier.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); aBuyPartsFromSupplier.CreatedBy = SessionManger.LoggedInUser(Session); aBuyPartsFromSupplier.CreatedDateTime = DateTime.Now; aBuyPartsFromSupplier.EditedBy = null; aBuyPartsFromSupplier.EditedDateTime = null; unitOfWork.BuyPartsFromSupplierRepository.Insert(aBuyPartsFromSupplier); unitOfWork.Save(); } if (otherExpense != null) { foreach (VM_BuyPartsFromSupplier othersExpenses in otherExpense) { aBuyPartsFromSupplier.RegistrationNo = registrationNo; aBuyPartsFromSupplier.BuyDate = buyDate; aBuyPartsFromSupplier.PartsId = null; aBuyPartsFromSupplier.SupplierId = null; aBuyPartsFromSupplier.Quantity = null; aBuyPartsFromSupplier.UnitPrice = null; aBuyPartsFromSupplier.Other = othersExpenses.Other; aBuyPartsFromSupplier.Price = othersExpenses.Price; aBuyPartsFromSupplier.StoreId = null; aBuyPartsFromSupplier.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); aBuyPartsFromSupplier.CreatedBy = SessionManger.LoggedInUser(Session); aBuyPartsFromSupplier.CreatedDateTime = DateTime.Now; aBuyPartsFromSupplier.EditedBy = null; aBuyPartsFromSupplier.EditedDateTime = null; unitOfWork.BuyPartsFromSupplierRepository.Insert(aBuyPartsFromSupplier); unitOfWork.Save(); } } } return(Json(new { success = true, successMessage = " Added Successfully!" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Model is not valid" }, JsonRequestBehavior.AllowGet)); } }
//public JsonResult SaveProductToSellPoint(int SellsPointId, int ProductionHouseStoreId,int shiftId,DateTime fromDate, List<VM_PHtoSPProductTransfer> productList) public JsonResult SaveProductToSellPoint(int SellsPointId, int ProductionHouseStoreId, int shiftId, List <VM_PHtoSPProductTransfer> productList) { try { var productionHouse = unitOfWork.ProductionHouseInformationRepository.Get().Where(x => x.OwnStore == ProductionHouseStoreId).FirstOrDefault(); //var mainStore = unitOfWork.StoreRepository.Get().Where(x => x.is_mainStore == true && x.store_id == ProductionHouseStoreId && x.store_id!=2).First(); var SellsPoint = unitOfWork.SellsPointRepository.Get().Where(x => x.SellsPointStoreId == SellsPointId).FirstOrDefault(); if (productionHouse != null) { foreach (VM_PHtoSPProductTransfer vmProduct in productList) { using (TransactionScope scope = new TransactionScope()) { tblPHtoSPProductTransfer aProduct = new tblPHtoSPProductTransfer(); aProduct.SellsPointId = SellsPoint.SellsPointId; aProduct.ProductionHouseId = productionHouse.ProductionHouseId; //aProduct.GroupId = groupId; aProduct.ShiftId = shiftId; //aProduct.TransferDate = fromDate; aProduct.TransferDate = DateTime.Now; aProduct.ProductId = vmProduct.ProductId; aProduct.Quantity = (decimal)vmProduct.Quantity; aProduct.Unit = vmProduct.Unit; aProduct.isIn = true; aProduct.RestaurantId = int.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); aProduct.CreatedBy = SessionManger.LoggedInUser(Session); aProduct.CreatedDateTime = DateTime.Now; aProduct.EditedBy = null; aProduct.EditedDateTime = null; unitOfWork.PHToSPProductTransferRepository.Insert(aProduct); unitOfWork.Save(); tblProductTransfer product = new tblProductTransfer(); product.StoreId = ProductionHouseStoreId; //product.GroupId = groupId; product.ShiftId = shiftId; //product.TransferDate = fromDate; product.TransferDate = DateTime.Now; product.ProductId = vmProduct.ProductId; product.Quantity = (decimal)vmProduct.Quantity; product.Unit = vmProduct.Unit; product.isOut = true; product.CreatedBy = SessionManger.LoggedInUser(Session); product.CreatedDateTime = DateTime.Now; product.EditedBy = null; product.EditedDateTime = null; unitOfWork.ProductTransferRepository.Insert(product); unitOfWork.Save(); tblProductTransfer product2 = new tblProductTransfer(); product2.StoreId = SellsPointId; //product2.GroupId = groupId; product2.ShiftId = shiftId; //product2.TransferDate = fromDate; product2.TransferDate = DateTime.Now; product2.ProductId = vmProduct.ProductId; product2.Quantity = (decimal)vmProduct.Quantity; product2.Unit = vmProduct.Unit; product2.isIn = true; product2.CreatedBy = SessionManger.LoggedInUser(Session); product2.CreatedDateTime = DateTime.Now; product2.EditedBy = null; product2.EditedDateTime = null; unitOfWork.ProductTransferRepository.Insert(product2); unitOfWork.Save(); scope.Complete(); } } } else { foreach (VM_PHtoSPProductTransfer vmProduct in productList) { using (TransactionScope scope = new TransactionScope()) { tblPHtoSPProductTransfer aProduct = new tblPHtoSPProductTransfer(); aProduct.SellsPointId = SellsPoint.SellsPointId; aProduct.ProductionHouseId = null; //aProduct.GroupId = groupId; aProduct.ShiftId = shiftId; //aProduct.TransferDate = fromDate; aProduct.TransferDate = DateTime.Now; aProduct.ProductId = vmProduct.ProductId; aProduct.Quantity = (decimal)vmProduct.Quantity; aProduct.Unit = vmProduct.Unit; aProduct.isIn = true; aProduct.RestaurantId = int.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); aProduct.CreatedBy = SessionManger.LoggedInUser(Session); aProduct.CreatedDateTime = DateTime.Now; aProduct.EditedBy = null; aProduct.EditedDateTime = null; unitOfWork.PHToSPProductTransferRepository.Insert(aProduct); unitOfWork.Save(); tblProductTransfer product = new tblProductTransfer(); product.StoreId = ProductionHouseStoreId; //product.GroupId = groupId; product.ShiftId = shiftId; //product.TransferDate = fromDate; product.TransferDate = DateTime.Now; product.ProductId = vmProduct.ProductId; product.Quantity = (decimal)vmProduct.Quantity; product.Unit = vmProduct.Unit; product.isOut = true; product.CreatedBy = SessionManger.LoggedInUser(Session); product.CreatedDateTime = DateTime.Now; product.EditedBy = null; product.EditedDateTime = null; unitOfWork.ProductTransferRepository.Insert(product); unitOfWork.Save(); tblProductTransfer product2 = new tblProductTransfer(); product2.StoreId = SellsPointId; //product2.GroupId = groupId; product2.ShiftId = shiftId; //product2.TransferDate = fromDate; product2.TransferDate = DateTime.Now; product2.ProductId = vmProduct.ProductId; product2.Quantity = (decimal)vmProduct.Quantity; product2.Unit = vmProduct.Unit; product2.isIn = true; product2.CreatedBy = SessionManger.LoggedInUser(Session); product2.CreatedDateTime = DateTime.Now; product2.EditedBy = null; product2.EditedDateTime = null; unitOfWork.ProductTransferRepository.Insert(product2); unitOfWork.Save(); scope.Complete(); } } } this.ProductionHouseToSellsPointReport(Convert.ToInt32(SellsPointId), Convert.ToInt32(ProductionHouseStoreId), productList); //unitOfWork.Save(); return(Json(new { success = true, successMessage = " Successfully Added" }, JsonRequestBehavior.AllowGet)); } catch (Exception exception) { return(Json(new { success = false, errorMessage = exception.Message }, JsonRequestBehavior.AllowGet)); } }
//public JsonResult AddSoldProductInfoToProductTransfer(int storeId, int shiftId, DateTime fromDate, List<VM_ProductSold> productsoldList) public JsonResult AddSoldProductInfoToProductTransfer(int storeId, int shiftId, List <VM_ProductSold> productsoldList) { try { foreach (var productsold in productsoldList) { using (TransactionScope scope = new TransactionScope()) { tblProductTransfer productTransfer = new tblProductTransfer(); productTransfer.StoreId = storeId; //productTransfer.GroupId = groupId; productTransfer.ShiftId = shiftId; //productTransfer.TransferDate = fromDate; productTransfer.TransferDate = DateTime.Now; productTransfer.ProductId = productsold.ProductId; productTransfer.Quantity = productsold.Quantity; productTransfer.Unit = unitOfWork.ProductRepository.GetByID(productsold.ProductId).Unit; productTransfer.UnitPrice = unitOfWork.ProductRepository.GetByID(productsold.ProductId).UnitPrice; productTransfer.isOut = true; productTransfer.DateTime = DateTime.Now; productTransfer.CreatedBy = SessionManger.LoggedInUser(Session); productTransfer.EditedBy = null; productTransfer.RestaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); productTransfer.CreatedDateTime = DateTime.Now; unitOfWork.ProductTransferRepository.Insert(productTransfer); unitOfWork.Save(); //add product to productSold table tblProductSold productSold = new tblProductSold(); productSold.StoreId = storeId; //productSold.GroupId = groupId; productSold.ShiftId = shiftId; //productSold.TransferDate = fromDate; productSold.TransferDate = DateTime.Now; productSold.ProductId = productsold.ProductId; productSold.Quantity = productsold.Quantity; productSold.Unit = unitOfWork.ProductRepository.GetByID(productsold.ProductId).Unit; productSold.UnitPrice = unitOfWork.ProductRepository.GetByID(productsold.ProductId).UnitPrice; productSold.DateTime = DateTime.Now; productSold.CreatedBy = SessionManger.LoggedInUser(Session); productSold.EditedBy = null; productSold.RestaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); productSold.CreatedDateTime = DateTime.Now; unitOfWork.ProductSoldRepository.Insert(productSold); unitOfWork.Save(); if (shiftId == 1) { unitOfWork.CustomRepository.sp_InsertTotalAmountDailyByShiftWise(); } else { unitOfWork.CustomRepository.sp_InsertTotalAmountDailyForNightShift(); } scope.Complete(); } } return(Json(new { success = true, successMessage = "Product Sold" })); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } //return Json(new { success = true, successMessage = "Product Sold" }); }
//[ValidateAntiForgeryToken] //public async Task<ActionResult> Register(RegisterViewModel model) //{ // if (ModelState.IsValid) // { // var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; // var result = await UserManager.CreateAsync(user, model.Password); // if (result.Succeeded) // { // await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false); // // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // // Send an email with this link // // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); // return RedirectToAction("Index", "Home"); // } // AddErrors(result); // } // // If we got this far, something failed, redisplay form // return View(model); //} public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var results = await UserManager.FindByNameAsync(model.UserName); if (results != null) { return(Json(new { success = false, errorMessage = "This User Name already exists" }, JsonRequestBehavior.AllowGet)); } else { // Create User var user = new ApplicationUser() { UserName = model.UserName, Email = model.Email, PhoneNumber = model.PhoneNumber }; var result = await UserManager.CreateAsync(user, model.Password); HanifWorkShop_DBEntity AgencyCal = new HanifWorkShop_DBEntity(); AspNetUser anu = new AspNetUser(); //AspNetUser userId = RestaurantCal.AspNetRoles.Select(a => a.Name == model.UserName).FirstOrDefault(); AspNetUser searchUser = AgencyCal.AspNetUsers.Where(a => a.UserName == model.UserName).FirstOrDefault(); decimal workShopId = SessionManger.WorkShopOfLoggedInUser(Session); if (result.Succeeded) { using (HanifWorkShop_DBEntity rc = new HanifWorkShop_DBEntity()) { try { tblWorkShopUser AgencyUser = new tblWorkShopUser(); AgencyUser.UserId = searchUser.Id; AgencyUser.workShop_id = workShopId; AgencyUser.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); AgencyUser.CreatedBy = SessionManger.LoggedInUser(Session); AgencyUser.CreatedDateTime = DateTime.Now; AgencyUser.EditedBy = null; AgencyUser.EditedDateTime = null; // RestaurantUser.is_admin = 0; //RestaurantUser.is_loggedIn = null; //RestaurantUser.last_logged_time = null; //RestaurantUser.approve_by = null; //RestaurantUser.approve_date = null; rc.tblWorkShopUsers.Add(AgencyUser); rc.SaveChanges(); return(Json(new { success = true, successMessage = "User has created Successfully." }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex }, JsonRequestBehavior.AllowGet)); } } } else { return(Json(new { success = false, errorMessage = "This Email has already taken." }, JsonRequestBehavior.AllowGet)); } } } else { return(Json(new { success = false, errorMessage = "Model is not Valid." }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Update(HttpPostedFileBase file, HttpPostedFileBase nidFile, HttpPostedFileBase drivingLicenseFile, VM_EmployeeInformation aEmployee) { if (ModelState.IsValid) { try { tblEmployeeInformation aEmployeeInformation = unitOfWork.EmployeeInformationRepository.GetByID(aEmployee.EmployeeId); var EmailExist = unitOfWork.EmployeeInformationRepository.Get() .Where(a => a.EmployeeEmail == aEmployee.EmployeeEmail && a.EmployeeEmail != aEmployeeInformation.EmployeeEmail && a.EmployeeEmail != "undefined" && a.EmployeeEmail != null && a.EmployeeEmail != " " && a.EmployeeEmail != "NULL" && a.EmployeeEmail != "null" && !string.IsNullOrEmpty(a.EmployeeEmail)).ToList(); if (!EmailExist.Any()) { string path = ""; if (file != null) { string pic = System.IO.Path.GetFileName(file.FileName); path = System.IO.Path.Combine( Server.MapPath("~/Image"), pic); // file is uploaded file.SaveAs(path); if (nidFile != null) { string picNid = System.IO.Path.GetFileName(nidFile.FileName); path = System.IO.Path.Combine( Server.MapPath("~/Image"), picNid); // file is uploaded nidFile.SaveAs(path); if (drivingLicenseFile != null) { string picDrivingLicense = System.IO.Path.GetFileName(drivingLicenseFile.FileName); path = System.IO.Path.Combine( Server.MapPath("~/Image"), picDrivingLicense); // file is uploaded drivingLicenseFile.SaveAs(path); aEmployeeInformation.EmployeeName = aEmployee.EmployeeName; aEmployeeInformation.EmployeeAddress = aEmployee.EmployeeAddress; aEmployeeInformation.ContactNumber = aEmployee.ContactNumber; aEmployeeInformation.EmployeeNid = aEmployee.EmployeeNid; aEmployeeInformation.EmployeeNidImage = "/Image/" + picNid; aEmployeeInformation.EmployeeEmail = aEmployee.EmployeeEmail; aEmployeeInformation.EmployeeImage = "/Image/" + pic; aEmployeeInformation.DesignationId = aEmployee.DesignationId; aEmployeeInformation.DrivingLicenseImage = "/Image/" + picDrivingLicense; aEmployeeInformation.Salary = aEmployee.Salary; aEmployeeInformation.RouteId = aEmployee.RouteId; aEmployeeInformation.EditedBy = SessionManger.LoggedInUser(Session); aEmployeeInformation.EditedDateTime = DateTime.Now; unitOfWork.EmployeeInformationRepository.Update(aEmployeeInformation); unitOfWork.Save(); } else { aEmployeeInformation.EmployeeName = aEmployee.EmployeeName; aEmployeeInformation.EmployeeAddress = aEmployee.EmployeeAddress; aEmployeeInformation.ContactNumber = aEmployee.ContactNumber; aEmployeeInformation.EmployeeNid = aEmployee.EmployeeNid; aEmployeeInformation.EmployeeNidImage = "/Image/" + picNid; aEmployeeInformation.EmployeeEmail = aEmployee.EmployeeEmail; aEmployeeInformation.EmployeeImage = "/Image/" + pic; aEmployeeInformation.DesignationId = aEmployee.DesignationId; aEmployeeInformation.DrivingLicenseImage = aEmployee.DrivingLicenseImage; aEmployeeInformation.Salary = aEmployee.Salary; aEmployeeInformation.RouteId = aEmployee.RouteId; aEmployeeInformation.EditedBy = SessionManger.LoggedInUser(Session); aEmployeeInformation.EditedDateTime = DateTime.Now; unitOfWork.EmployeeInformationRepository.Update(aEmployeeInformation); unitOfWork.Save(); } } else { if (drivingLicenseFile != null) { string picDrivingLicense = System.IO.Path.GetFileName(drivingLicenseFile.FileName); path = System.IO.Path.Combine( Server.MapPath("~/Image"), picDrivingLicense); // file is uploaded drivingLicenseFile.SaveAs(path); aEmployeeInformation.EmployeeName = aEmployee.EmployeeName; aEmployeeInformation.EmployeeAddress = aEmployee.EmployeeAddress; aEmployeeInformation.ContactNumber = aEmployee.ContactNumber; aEmployeeInformation.EmployeeNid = aEmployee.EmployeeNid; aEmployeeInformation.EmployeeNidImage = aEmployee.EmployeeNidImage; aEmployeeInformation.EmployeeEmail = aEmployee.EmployeeEmail; aEmployeeInformation.EmployeeImage = "/Image/" + pic; aEmployeeInformation.DesignationId = aEmployee.DesignationId; aEmployeeInformation.DrivingLicenseImage = "/Image/" + picDrivingLicense; aEmployeeInformation.Salary = aEmployee.Salary; aEmployeeInformation.RouteId = aEmployee.RouteId; aEmployeeInformation.EditedBy = SessionManger.LoggedInUser(Session); aEmployeeInformation.EditedDateTime = DateTime.Now; unitOfWork.EmployeeInformationRepository.Update(aEmployeeInformation); unitOfWork.Save(); } else { aEmployeeInformation.EmployeeName = aEmployee.EmployeeName; aEmployeeInformation.EmployeeAddress = aEmployee.EmployeeAddress; aEmployeeInformation.ContactNumber = aEmployee.ContactNumber; aEmployeeInformation.EmployeeNid = aEmployee.EmployeeNid; aEmployeeInformation.EmployeeNidImage = aEmployee.EmployeeNidImage; aEmployeeInformation.EmployeeEmail = aEmployee.EmployeeEmail; aEmployeeInformation.EmployeeImage = "/Image/" + pic; aEmployeeInformation.DesignationId = aEmployee.DesignationId; aEmployeeInformation.DrivingLicenseImage = aEmployee.DrivingLicenseImage; aEmployeeInformation.Salary = aEmployee.Salary; aEmployeeInformation.RouteId = aEmployee.RouteId; aEmployeeInformation.EditedBy = SessionManger.LoggedInUser(Session); aEmployeeInformation.EditedDateTime = DateTime.Now; unitOfWork.EmployeeInformationRepository.Update(aEmployeeInformation); unitOfWork.Save(); } } } else { if (nidFile != null) { string picNid = System.IO.Path.GetFileName(nidFile.FileName); path = System.IO.Path.Combine( Server.MapPath("~/Image"), picNid); // file is uploaded nidFile.SaveAs(path); if (drivingLicenseFile != null) { string picDrivingLicense = System.IO.Path.GetFileName(drivingLicenseFile.FileName); path = System.IO.Path.Combine( Server.MapPath("~/Image"), picDrivingLicense); // file is uploaded drivingLicenseFile.SaveAs(path); aEmployeeInformation.EmployeeName = aEmployee.EmployeeName; aEmployeeInformation.EmployeeAddress = aEmployee.EmployeeAddress; aEmployeeInformation.ContactNumber = aEmployee.ContactNumber; aEmployeeInformation.EmployeeNid = aEmployee.EmployeeNid; aEmployeeInformation.EmployeeNidImage = "/Image/" + picNid; aEmployeeInformation.EmployeeEmail = aEmployee.EmployeeEmail; aEmployeeInformation.EmployeeImage = aEmployee.EmployeeImage; aEmployeeInformation.DesignationId = aEmployee.DesignationId; aEmployeeInformation.DrivingLicenseImage = "/Image/" + picDrivingLicense; aEmployeeInformation.Salary = aEmployee.Salary; aEmployeeInformation.RouteId = aEmployee.RouteId; aEmployeeInformation.EditedBy = SessionManger.LoggedInUser(Session); aEmployeeInformation.EditedDateTime = DateTime.Now; unitOfWork.EmployeeInformationRepository.Update(aEmployeeInformation); unitOfWork.Save(); } else { aEmployeeInformation.EmployeeName = aEmployee.EmployeeName; aEmployeeInformation.EmployeeAddress = aEmployee.EmployeeAddress; aEmployeeInformation.ContactNumber = aEmployee.ContactNumber; aEmployeeInformation.EmployeeNid = aEmployee.EmployeeNid; aEmployeeInformation.EmployeeNidImage = "/Image/" + picNid; aEmployeeInformation.EmployeeEmail = aEmployee.EmployeeEmail; aEmployeeInformation.EmployeeImage = aEmployee.EmployeeImage; aEmployeeInformation.DesignationId = aEmployee.DesignationId; aEmployeeInformation.DrivingLicenseImage = aEmployee.DrivingLicenseImage; aEmployeeInformation.Salary = aEmployee.Salary; aEmployeeInformation.RouteId = aEmployee.RouteId; aEmployeeInformation.EditedBy = SessionManger.LoggedInUser(Session); aEmployeeInformation.EditedDateTime = DateTime.Now; unitOfWork.EmployeeInformationRepository.Update(aEmployeeInformation); unitOfWork.Save(); } } else { if (drivingLicenseFile != null) { string picDrivingLicense = System.IO.Path.GetFileName(drivingLicenseFile.FileName); path = System.IO.Path.Combine( Server.MapPath("~/Image"), picDrivingLicense); // file is uploaded drivingLicenseFile.SaveAs(path); aEmployeeInformation.EmployeeName = aEmployee.EmployeeName; aEmployeeInformation.EmployeeAddress = aEmployee.EmployeeAddress; aEmployeeInformation.ContactNumber = aEmployee.ContactNumber; aEmployeeInformation.EmployeeNid = aEmployee.EmployeeNid; aEmployeeInformation.EmployeeNidImage = aEmployee.EmployeeNidImage; aEmployeeInformation.EmployeeEmail = aEmployee.EmployeeEmail; aEmployeeInformation.EmployeeImage = aEmployee.EmployeeImage; aEmployeeInformation.DesignationId = aEmployee.DesignationId; aEmployeeInformation.DrivingLicenseImage = "/Image/" + picDrivingLicense; aEmployeeInformation.Salary = aEmployee.Salary; aEmployeeInformation.RouteId = aEmployee.RouteId; aEmployeeInformation.EditedBy = SessionManger.LoggedInUser(Session); aEmployeeInformation.EditedDateTime = DateTime.Now; unitOfWork.EmployeeInformationRepository.Update(aEmployeeInformation); unitOfWork.Save(); } else { aEmployeeInformation.EmployeeName = aEmployee.EmployeeName; aEmployeeInformation.EmployeeAddress = aEmployee.EmployeeAddress; aEmployeeInformation.ContactNumber = aEmployee.ContactNumber; aEmployeeInformation.EmployeeNid = aEmployee.EmployeeNid; aEmployeeInformation.EmployeeNidImage = aEmployee.EmployeeNidImage; aEmployeeInformation.EmployeeEmail = aEmployee.EmployeeEmail; aEmployeeInformation.EmployeeImage = aEmployee.EmployeeImage; aEmployeeInformation.DesignationId = aEmployee.DesignationId; aEmployeeInformation.DrivingLicenseImage = aEmployee.DrivingLicenseImage; aEmployeeInformation.Salary = aEmployee.Salary; aEmployeeInformation.RouteId = aEmployee.RouteId; aEmployeeInformation.EditedBy = SessionManger.LoggedInUser(Session); aEmployeeInformation.EditedDateTime = DateTime.Now; unitOfWork.EmployeeInformationRepository.Update(aEmployeeInformation); unitOfWork.Save(); } } } return(Json(new { success = true, successMessage = "Employee Information Update Successfully" })); } else { return(Json(new { success = false, errorMessage = "The email already exist" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Model Is not valid" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult SaveEmployeeInformation(HttpPostedFileBase file, HttpPostedFileBase nidFile, HttpPostedFileBase drivingLicenseFile, VM_EmployeeInformation aEmployee) { //string emptyEmail = "undefined"; var EmailExist = unitOfWork.EmployeeInformationRepository.Get() .Where(a => a.EmployeeEmail == aEmployee.EmployeeEmail && a.EmployeeEmail != "undefined" && a.EmployeeEmail != "").ToList(); if (ModelState.IsValid) { try { if (!EmailExist.Any()) { string path = ""; if (file != null) { string pic = System.IO.Path.GetFileName(file.FileName); path = System.IO.Path.Combine( Server.MapPath("~/Image"), pic); // file is uploaded file.SaveAs(path); if (nidFile != null) { string picNid = System.IO.Path.GetFileName(nidFile.FileName); path = System.IO.Path.Combine( Server.MapPath("~/Image"), picNid); // file is uploaded nidFile.SaveAs(path); if (drivingLicenseFile != null) { string picDrivingLicense = System.IO.Path.GetFileName(drivingLicenseFile.FileName); path = System.IO.Path.Combine( Server.MapPath("~/Image"), picDrivingLicense); // file is uploaded drivingLicenseFile.SaveAs(path); tblEmployeeInformation employee = new tblEmployeeInformation(); employee.EmployeeName = aEmployee.EmployeeName; employee.EmployeeAddress = aEmployee.EmployeeAddress; employee.ContactNumber = aEmployee.ContactNumber; employee.EmployeeNid = aEmployee.EmployeeNid; employee.EmployeeNidImage = "/Image/" + picNid; employee.EmployeeEmail = aEmployee.EmployeeEmail; employee.EmployeeImage = "/Image/" + pic; employee.DesignationId = aEmployee.DesignationId; employee.DrivingLicenseImage = "/Image/" + picDrivingLicense; employee.Salary = aEmployee.Salary; employee.RouteId = aEmployee.RouteId; employee.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); employee.CreatedBy = SessionManger.LoggedInUser(Session); employee.CreatedDateTime = DateTime.Now; employee.EditedBy = null; employee.EditedDateTime = null; unitOfWork.EmployeeInformationRepository.Insert(employee); unitOfWork.Save(); } else { tblEmployeeInformation employee = new tblEmployeeInformation(); employee.EmployeeName = aEmployee.EmployeeName; employee.EmployeeAddress = aEmployee.EmployeeAddress; employee.ContactNumber = aEmployee.ContactNumber; employee.EmployeeNid = aEmployee.EmployeeNid; employee.EmployeeNidImage = "/Image/" + picNid; employee.EmployeeEmail = aEmployee.EmployeeEmail; employee.EmployeeImage = "/Image/" + pic; employee.DesignationId = aEmployee.DesignationId; employee.DrivingLicenseImage = aEmployee.DrivingLicenseImage; employee.Salary = aEmployee.Salary; employee.RouteId = aEmployee.RouteId; employee.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); employee.CreatedBy = SessionManger.LoggedInUser(Session); employee.CreatedDateTime = DateTime.Now; employee.EditedBy = null; employee.EditedDateTime = null; unitOfWork.EmployeeInformationRepository.Insert(employee); unitOfWork.Save(); } } else { if (drivingLicenseFile != null) { string picDrivingLicense = System.IO.Path.GetFileName(drivingLicenseFile.FileName); path = System.IO.Path.Combine( Server.MapPath("~/Image"), picDrivingLicense); // file is uploaded drivingLicenseFile.SaveAs(path); tblEmployeeInformation employee = new tblEmployeeInformation(); employee.EmployeeName = aEmployee.EmployeeName; employee.EmployeeAddress = aEmployee.EmployeeAddress; employee.ContactNumber = aEmployee.ContactNumber; employee.EmployeeNid = aEmployee.EmployeeNid; employee.EmployeeNidImage = aEmployee.EmployeeNidImage; employee.EmployeeEmail = aEmployee.EmployeeEmail; employee.EmployeeImage = "/Image/" + pic; employee.DesignationId = aEmployee.DesignationId; employee.DrivingLicenseImage = "/Image/" + picDrivingLicense; employee.Salary = aEmployee.Salary; employee.RouteId = aEmployee.RouteId; employee.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); employee.CreatedBy = SessionManger.LoggedInUser(Session); employee.CreatedDateTime = DateTime.Now; employee.EditedBy = null; employee.EditedDateTime = null; unitOfWork.EmployeeInformationRepository.Insert(employee); unitOfWork.Save(); } else { tblEmployeeInformation employee = new tblEmployeeInformation(); employee.EmployeeName = aEmployee.EmployeeName; employee.EmployeeAddress = aEmployee.EmployeeAddress; employee.ContactNumber = aEmployee.ContactNumber; employee.EmployeeNid = aEmployee.EmployeeNid; employee.EmployeeNidImage = aEmployee.EmployeeNidImage; employee.EmployeeEmail = aEmployee.EmployeeEmail; employee.EmployeeImage = "/Image/" + pic; employee.DesignationId = aEmployee.DesignationId; employee.DrivingLicenseImage = aEmployee.DrivingLicenseImage; employee.Salary = aEmployee.Salary; employee.RouteId = aEmployee.RouteId; employee.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); employee.CreatedBy = SessionManger.LoggedInUser(Session); employee.CreatedDateTime = DateTime.Now; employee.EditedBy = null; employee.EditedDateTime = null; unitOfWork.EmployeeInformationRepository.Insert(employee); unitOfWork.Save(); } } } else { if (nidFile != null) { string picNid = System.IO.Path.GetFileName(nidFile.FileName); path = System.IO.Path.Combine( Server.MapPath("~/Image"), picNid); // file is uploaded nidFile.SaveAs(path); if (drivingLicenseFile != null) { string picDrivingLicense = System.IO.Path.GetFileName(drivingLicenseFile.FileName); path = System.IO.Path.Combine( Server.MapPath("~/Image"), picDrivingLicense); // file is uploaded drivingLicenseFile.SaveAs(path); tblEmployeeInformation employee = new tblEmployeeInformation(); employee.EmployeeName = aEmployee.EmployeeName; employee.EmployeeAddress = aEmployee.EmployeeAddress; employee.ContactNumber = aEmployee.ContactNumber; employee.EmployeeNid = aEmployee.EmployeeNid; employee.EmployeeNidImage = "/Image/" + picNid; employee.EmployeeEmail = aEmployee.EmployeeEmail; employee.EmployeeImage = aEmployee.EmployeeImage; employee.DesignationId = aEmployee.DesignationId; employee.DrivingLicenseImage = "/Image/" + picDrivingLicense; employee.Salary = aEmployee.Salary; employee.RouteId = aEmployee.RouteId; employee.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); employee.CreatedBy = SessionManger.LoggedInUser(Session); employee.CreatedDateTime = DateTime.Now; employee.EditedBy = null; employee.EditedDateTime = null; unitOfWork.EmployeeInformationRepository.Insert(employee); unitOfWork.Save(); } else { tblEmployeeInformation employee = new tblEmployeeInformation(); employee.EmployeeName = aEmployee.EmployeeName; employee.EmployeeAddress = aEmployee.EmployeeAddress; employee.ContactNumber = aEmployee.ContactNumber; employee.EmployeeNid = aEmployee.EmployeeNid; employee.EmployeeNidImage = "/Image/" + picNid; employee.EmployeeEmail = aEmployee.EmployeeEmail; employee.EmployeeImage = aEmployee.EmployeeImage; employee.DesignationId = aEmployee.DesignationId; employee.DrivingLicenseImage = aEmployee.DrivingLicenseImage; employee.Salary = aEmployee.Salary; employee.RouteId = aEmployee.RouteId; employee.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); employee.CreatedBy = SessionManger.LoggedInUser(Session); employee.CreatedDateTime = DateTime.Now; employee.EditedBy = null; employee.EditedDateTime = null; unitOfWork.EmployeeInformationRepository.Insert(employee); unitOfWork.Save(); } } else { if (drivingLicenseFile != null) { string picDrivingLicense = System.IO.Path.GetFileName(drivingLicenseFile.FileName); path = System.IO.Path.Combine( Server.MapPath("~/Image"), picDrivingLicense); // file is uploaded drivingLicenseFile.SaveAs(path); tblEmployeeInformation employee = new tblEmployeeInformation(); employee.EmployeeName = aEmployee.EmployeeName; employee.EmployeeAddress = aEmployee.EmployeeAddress; employee.ContactNumber = aEmployee.ContactNumber; employee.EmployeeNid = aEmployee.EmployeeNid; employee.EmployeeNidImage = aEmployee.EmployeeNidImage; employee.EmployeeEmail = aEmployee.EmployeeEmail; employee.EmployeeImage = aEmployee.EmployeeImage; employee.DesignationId = aEmployee.DesignationId; employee.DrivingLicenseImage = "/Image/" + picDrivingLicense; employee.Salary = aEmployee.Salary; employee.RouteId = aEmployee.RouteId; employee.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); employee.CreatedBy = SessionManger.LoggedInUser(Session); employee.CreatedDateTime = DateTime.Now; employee.EditedBy = null; employee.EditedDateTime = null; unitOfWork.EmployeeInformationRepository.Insert(employee); unitOfWork.Save(); } else { tblEmployeeInformation employee = new tblEmployeeInformation(); employee.EmployeeName = aEmployee.EmployeeName; employee.EmployeeAddress = aEmployee.EmployeeAddress; employee.ContactNumber = aEmployee.ContactNumber; employee.EmployeeNid = aEmployee.EmployeeNid; employee.EmployeeNidImage = aEmployee.EmployeeNidImage; employee.EmployeeEmail = aEmployee.EmployeeEmail; employee.EmployeeImage = aEmployee.EmployeeImage; employee.DesignationId = aEmployee.DesignationId; employee.DrivingLicenseImage = aEmployee.DrivingLicenseImage; employee.Salary = aEmployee.Salary; employee.RouteId = aEmployee.RouteId; employee.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); employee.CreatedBy = SessionManger.LoggedInUser(Session); employee.CreatedDateTime = DateTime.Now; employee.EditedBy = null; employee.EditedDateTime = null; unitOfWork.EmployeeInformationRepository.Insert(employee); unitOfWork.Save(); } } } return(Json(new { success = true, successMessage = "Employee Information Added Successfully" })); } else { return(Json(new { success = false, errorMessage = "The email already exist" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Please Fill Up all required field." }, JsonRequestBehavior.AllowGet)); } }