/// <summary> /// Size Type /// </summary> #region Size Type public List <ProductSizeType> GetProductSizeType(string QueryConditionPartParam) { List <ProductSizeType> GridRecords = new List <ProductSizeType>(); var command = dbContext.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "sp_ProductSizeType_Get"; command.OpenConnection(); var reader = command.OpenReader(); while (reader.Read()) { ProductSizeType GridRecord = new ProductSizeType() { RowId = reader.ValidateColumnExistExtractAndCastTo <int>("RowId"), TypeName = reader.ValidateColumnExistExtractAndCastTo <string>("TypeName"), TypeCode = reader.ValidateColumnExistExtractAndCastTo <string>("TypeCode"), MeasureDimensionId = reader.ValidateColumnExistExtractAndCastTo <int>("MeasureDimensionId"), CreatedOnUtc = reader.ValidateColumnExistExtractAndCastTo <DateTime>("CreatedOnUtc"), Description = reader.ValidateColumnExistExtractAndCastTo <string>("Description"), MeasurementDimension = reader.ValidateColumnExistExtractAndCastTo <string>("MeasurementDimension"), }; GridRecords.Add(GridRecord); } ; command.CloseConnection(); return(GridRecords); }
// GET: /ProductMaster/Create public ActionResult Create() { ProductSizeType vm = new ProductSizeType(); vm.IsActive = true; return(View("Create", vm)); }
public IList <ProductSizeType> UpdateProductSizeType(List <ProductSizeType> tasks) { var result = new List <ProductSizeType>(); var command = dbContext.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "sp_ProductSizeType_u"; SqlParameter[] sqlParams = new SqlParameter[5]; sqlParams[0] = new SqlParameter("@RowId", DbType.Int32); sqlParams[1] = new SqlParameter("@TypeName", DbType.String); sqlParams[2] = new SqlParameter("@TypeCode", DbType.String); sqlParams[3] = new SqlParameter("@MeasureDimensionId", DbType.Int32); sqlParams[4] = new SqlParameter("@Description", DbType.String); using (var transaction = new TransactionScope()) { using (command.Connection) { if (command.Connection.State == ConnectionState.Closed) { command.Connection.Open(); } foreach (var item in tasks) { var data = new ProductSizeType(); command.Parameters.Clear(); sqlParams[0].Value = (object)item.RowId; sqlParams[1].Value = (object)item.TypeName; sqlParams[2].Value = (object)item.TypeCode; sqlParams[3].Value = (object)item.MeasureDimensionId; sqlParams[4].Value = (object)item.Description; command.Parameters.Add(sqlParams[0]); command.Parameters.Add(sqlParams[1]); command.Parameters.Add(sqlParams[2]); command.Parameters.Add(sqlParams[3]); command.Parameters.Add(sqlParams[4]); try { command.ExecuteNonQuery(); data.RowId = item.RowId; data.Message = ""; } catch (Exception ex) { data.RowId = item.RowId; data.Message = "Error while updating record."; } finally { result.Add(data); } } } transaction.Complete(); } return(result); }
// GET: /ProductMaster/Edit/5 public ActionResult Edit(int id) { ProductSizeType pt = _ProductSizeTypeService.Find(id); if (pt == null) { return(HttpNotFound()); } return(View("Create", pt)); }
public IActionResult AddProductSizeType([FromBody] ProductSizeType request) { var response = new OperationResponse <bool>(); try { response.Data = _specificationService.AddProductSizeType(request); } catch (Exception exception) { response.State = ResponseState.Error; response.Messages.Add(exception.Message); _logger.LogError(exception, "Error in AddProductSizeType ==>" + exception.StackTrace, request); } return(new JsonResult(response)); }
// GET: /ProductMaster/Delete/5 public ActionResult Delete(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProductSizeType ProductSizeType = _ProductSizeTypeService.Find(id); if (ProductSizeType == null) { return(HttpNotFound()); } ReasonViewModel vm = new ReasonViewModel() { id = id, }; return(PartialView("_Reason", vm)); }
public bool AddProductSizeType(ProductSizeType request) { int result; var command = dbContext.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "sp_ProductSizeType_i"; command.AddParameter("@TypeName", request.TypeName, DbType.String); command.AddParameter("@TypeCode", request.TypeCode, DbType.String); command.AddParameter("@MeasureDimensionId", request.MeasureDimensionId, DbType.Int32); command.AddParameter("@Description", request.Description, DbType.String); try { command.OpenConnection(); result = command.ExecuteNonQuery(); } finally { command.CloseConnection(); } return(result > 0); }
public ProductSizeType Add(ProductSizeType pt) { _unitOfWork.Repository <ProductSizeType>().Insert(pt); return(pt); }
public void Update(ProductSizeType pt) { pt.ObjectState = ObjectState.Modified; _unitOfWork.Repository <ProductSizeType>().Update(pt); }
public void Delete(ProductSizeType pt) { _unitOfWork.Repository <ProductSizeType>().Delete(pt); }
public ProductSizeType Create(ProductSizeType pt) { pt.ObjectState = ObjectState.Added; _unitOfWork.Repository <ProductSizeType>().Insert(pt); return(pt); }
public ActionResult Post(ProductSizeType vm) { ProductSizeType pt = vm; if (ModelState.IsValid) { if (vm.ProductSizeTypeId <= 0) { pt.CreatedDate = DateTime.Now; pt.ModifiedDate = DateTime.Now; pt.CreatedBy = User.Identity.Name; pt.ModifiedBy = User.Identity.Name; pt.ObjectState = Model.ObjectState.Added; _ProductSizeTypeService.Create(pt); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(View("Create", vm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductSizeType).DocumentTypeId, DocId = pt.ProductSizeTypeId, ActivityType = (int)ActivityTypeContants.Added, })); return(RedirectToAction("Create").Success("Data saved successfully")); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); ProductSizeType temp = _ProductSizeTypeService.Find(pt.ProductSizeTypeId); ProductSizeType ExRec = Mapper.Map <ProductSizeType>(temp); temp.ProductSizeTypeName = pt.ProductSizeTypeName; temp.IsActive = pt.IsActive; temp.ModifiedDate = DateTime.Now; temp.ModifiedBy = User.Identity.Name; temp.ObjectState = Model.ObjectState.Modified; _ProductSizeTypeService.Update(temp); LogList.Add(new LogTypeViewModel { ExObj = ExRec, Obj = temp, }); XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(View("Create", pt)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductSizeType).DocumentTypeId, DocId = temp.ProductSizeTypeId, ActivityType = (int)ActivityTypeContants.Modified, xEModifications = Modifications, })); return(RedirectToAction("Index").Success("Data saved successfully")); } } return(View("Create", vm)); }