public ActionResult GetMeasuringUnitView() { MeasuringUnitModel model = new MeasuringUnitModel(); var MeasuringUnitId = Request.QueryString["measuringunitid"]; try { MUClient = new MeasuringUnitServiceClient(); MeasuringUnitDto measuringunitdto = MUClient.GetById(MeasuringUnitId != null ? Convert.ToInt32(MeasuringUnitId) : 0); model.UnitType = measuringunitdto.UnitType; model.UnitId = measuringunitdto.UnitId; if (model.UnitType == Cams.Common.UnitType.Weight) { model.MeasurementUnitWeight = measuringunitdto.MeasurementUnit; model.EquivalentUnitWeight = measuringunitdto.EquivalentUnit; } else { model.MeasurementUnitQuantity = measuringunitdto.MeasurementUnit; model.EquivalentUnitQuantity = measuringunitdto.EquivalentUnit; } } catch (Exception ex) { return(View("ErrorPage")); } finally { if (MUClient != null) { MUClient.Close(); } } return(View("MeasuringUnitView", model)); }
public virtual void CreateMeasuringUnit() { var measuringunitdto = new MeasuringUnitDto { UnitType = Common.UnitType.Weight, MeasurementUnit = "Quintal", EquivalentUnit = "100", CAId = 1, CreatedBy = 1, ModifiedBy = 1 }; this.MeasuringUnitInstance = this.MeasuringUnitService.Create(measuringunitdto, CurrentUserInstance.UserName); Assert.IsFalse(this.MeasuringUnitInstance.UnitId == 0, "UnitId should have been updated"); Assert.AreEqual(this.MeasuringUnitInstance.MeasurementUnit, MeasuringUnitInstance.MeasurementUnit, "Measuring Units are different"); }
public ActionResult AddMeasuringUnitIndex() { MeasuringUnitModel model = new MeasuringUnitModel(); string mode = Request.QueryString["mode"] != null ? Request.QueryString["mode"].ToString() : string.Empty; var MeasuringUnitId = Request.QueryString["measuringunitid"] != null ? Request.QueryString["measuringunitid"] : null; try { MUClient = new MeasuringUnitServiceClient(); if (mode == "edit") { FormMode = mode; MeasuringUnitDto measuringunitdto = MUClient.GetById(MeasuringUnitId != null ? Convert.ToInt32(MeasuringUnitId) : 0); Id = measuringunitdto.UnitId; model.UnitType = measuringunitdto.UnitType; model.UnitId = measuringunitdto.UnitId; if (model.UnitType == Cams.Common.UnitType.Weight) { model.MeasurementUnitWeight = measuringunitdto.MeasurementUnit; model.EquivalentUnitWeight = measuringunitdto.EquivalentUnit; } else { model.MeasurementUnitQuantity = measuringunitdto.MeasurementUnit; model.EquivalentUnitQuantity = measuringunitdto.EquivalentUnit; } } } catch (Exception ex) { return(View("ErrorPage")); } finally { if (MUClient != null) { MUClient.Close(); } } return(View("AddMeasuringUnit", model)); }
public ActionResult AddMeasuringUnit(MeasuringUnitModel model) { ViewData["Error"] = null; TempData["Success"] = null; try { MUClient = new MeasuringUnitServiceClient(); if (ModelState.IsValid && ((!String.IsNullOrEmpty(model.MeasurementUnitWeight) && !String.IsNullOrEmpty(model.EquivalentUnitWeight)) || (!String.IsNullOrEmpty(model.MeasurementUnitQuantity) && !String.IsNullOrEmpty(model.EquivalentUnitQuantity)))) { MeasuringUnitDto measuringunitdto = new MeasuringUnitDto(); UserDto currentUserDto = (UserDto)Session[Constants.SKCURRENTUSER]; measuringunitdto.UnitType = model.UnitType; measuringunitdto.CAId = Convert.ToInt32(Helper.GetCAIdOfUser(currentUserDto)); measuringunitdto.CreatedBy = currentUserDto.UserId; measuringunitdto.ModifiedBy = currentUserDto.UserId; if (!String.IsNullOrEmpty(model.MeasurementUnitWeight) && !String.IsNullOrEmpty(model.EquivalentUnitWeight)) { measuringunitdto.MeasurementUnit = model.MeasurementUnitWeight; measuringunitdto.EquivalentUnit = model.EquivalentUnitWeight; } if (!String.IsNullOrEmpty(model.MeasurementUnitQuantity) && !String.IsNullOrEmpty(model.EquivalentUnitQuantity)) { measuringunitdto.MeasurementUnit = model.MeasurementUnitQuantity; measuringunitdto.EquivalentUnit = model.EquivalentUnitQuantity; } if (FormMode == "edit") { measuringunitdto.UnitId = Id; measuringunitdto = MUClient.Update(measuringunitdto, currentUserDto.UserName); } else { measuringunitdto.CreatedBy = currentUserDto.UserId; measuringunitdto = MUClient.Create(measuringunitdto, currentUserDto.UserName); } if (measuringunitdto.Response.HasWarning) { int i = 0; foreach (BusinessWarning bw in measuringunitdto.Response.BusinessWarnings) { if (bw.Message == Constants.BRMUMEASURINGUNITVALIDATION) { ModelState.AddModelError("err" + (++i).ToString(), ErrorAndValidationMessages.BRMUMeasuringUnitValidation); } } } else { if (FormMode == "edit") { TempData["StateSaved"] = ClientResources.MUUpdate; } else { TempData["StateSaved"] = string.Format(ClientResources.MUSaved, measuringunitdto.MeasurementUnit, measuringunitdto.UnitType); } FormMode = string.Empty; return(RedirectToAction("MeasuringUnitListIndex", "ClientMasters")); } } else { ModelState.AddModelError("err", ErrorAndValidationMessages.AddMUDataRequired); } } catch (Exception ex) { return(View("ErrorPage")); } finally { if (MUClient != null) { MUClient.Close(); } } return(View(model)); }
public MeasuringUnitDto Create(MeasuringUnitDto measuringunitdto, string userName) { return(ExecuteCommand(() => Service.Create(measuringunitdto, userName))); }
public MeasuringUnitDto Create(MeasuringUnitDto measuringunitdto, string userName) { return(ExecuteCommand(proxy => proxy.Create(measuringunitdto, userName))); }