public ActionResult AddLabourChargeTypeIndex()
        {
            LabourChargeTypeModel model = new LabourChargeTypeModel();
            string mode           = Request.QueryString["mode"] != null ? Request.QueryString["mode"].ToString() : string.Empty;
            var    LabourChargeId = Request.QueryString["labourchargeid"] != null ? Request.QueryString["labourchargeid"] : null;

            try
            {
                LCTClient = new LabourChargeTypeServiceClient();
                if (mode == "edit")
                {
                    FormMode = mode;
                    LabourChargeTypeDto labourchargedto = LCTClient.GetById(LabourChargeId != null ? Convert.ToInt32(LabourChargeId) : 0);
                    Id = labourchargedto.LabourChargeId;
                    model.LabourCharge = labourchargedto.LabourCharge;
                }
            }
            catch (Exception ex)
            {
                return(View("ErrorPage"));
            }
            finally
            {
                if (LCTClient != null)
                {
                    LCTClient.Close();
                }
            }
            return(View("AddLabourChargeType", model));
        }
        public ActionResult GetLabourChargeTypeView()
        {
            LabourChargeTypeModel model = new LabourChargeTypeModel();
            var LabourChargeId          = Request.QueryString["labourchargeid"];

            try
            {
                LCTClient = new LabourChargeTypeServiceClient();
                LabourChargeTypeDto LCTdto = LCTClient.GetById(LabourChargeId != null ? Convert.ToInt32(LabourChargeId) : 0);
                model.LabourChargeId = LCTdto.LabourChargeId;
                model.LabourCharge   = LCTdto.LabourCharge;
            }
            catch (Exception ex)
            {
                return(View("ErrorPage"));
            }
            finally
            {
                if (LCTClient != null)
                {
                    LCTClient.Close();
                }
            }
            return(View("LabourChargeTypeView", model));
        }
Beispiel #3
0
        public virtual void CreateLabourCharge()
        {
            var LabourChargeTypedto = new LabourChargeTypeDto
            {
                LabourCharge = "Kata1234",
                CAId         = 1,
                CreatedBy    = -1,
                ModifiedBy   = -1
            };

            this.LabourChargeInstance = this.LabourChargeTypeService.Create(LabourChargeTypedto, CurrentUserInstance.UserName);
            Assert.IsFalse(this.LabourChargeInstance.LabourChargeId == 0, "LabourChargeId should have been updated");
            Assert.AreEqual(this.LabourChargeInstance.LabourCharge, LabourChargeTypedto.LabourCharge, "LabourCharge are different");
        }
Beispiel #4
0
        public override ChargesPayableToDto EntityToEntityDto(ChargesPayableTo entity)
        {
            ChargesPayableToDto chargespayabletodto = Mapper.Map <ChargesPayableTo, ChargesPayableToDto>(entity);

            if (entity != null)
            {
                chargespayabletodto.LabourCharges.Clear();
                if (entity.LabourCharges != null)
                {
                    foreach (LabourChargeType LabourCharges in entity.LabourCharges)
                    {
                        LabourChargeTypeDto LabourChargesdto = new LabourChargeTypeDto();
                        LabourChargesdto = Mapper.Map <LabourChargeType, LabourChargeTypeDto>(LabourCharges);
                        chargespayabletodto.LabourCharges.Add(LabourChargesdto);
                    }
                }

                chargespayabletodto.D1LabourCharges.Clear();
                if (entity.D1LabourCharges != null)
                {
                    foreach (LabourChargeType D1LabourCharges in entity.D1LabourCharges)
                    {
                        LabourChargeTypeDto LabourChargesdto = new LabourChargeTypeDto();
                        LabourChargesdto = Mapper.Map <LabourChargeType, LabourChargeTypeDto>(D1LabourCharges);
                        chargespayabletodto.D1LabourCharges.Add(LabourChargesdto);
                    }
                }

                chargespayabletodto.D2LabourCharges.Clear();
                if (entity.D2LabourCharges != null)
                {
                    foreach (LabourChargeType D2LabourCharges in entity.D2LabourCharges)
                    {
                        LabourChargeTypeDto LabourChargesdto = new LabourChargeTypeDto();
                        LabourChargesdto = Mapper.Map <LabourChargeType, LabourChargeTypeDto>(D2LabourCharges);
                        chargespayabletodto.D2LabourCharges.Add(LabourChargesdto);
                    }
                }
            }
            return(chargespayabletodto);
        }
Beispiel #5
0
 public LabourChargeTypeDto Create(LabourChargeTypeDto labourchargetypeDto, string userName)
 {
     return(ExecuteCommand(proxy => proxy.Create(labourchargetypeDto, userName)));
 }
        public ActionResult AddLabourChargeType(LabourChargeTypeModel model)
        {
            ViewData["Error"]   = null;
            TempData["Success"] = null;
            try
            {
                LCTClient = new LabourChargeTypeServiceClient();
                if (ModelState.IsValid)
                {
                    LabourChargeTypeDto labourchargedto = new LabourChargeTypeDto();
                    UserDto             currentUserDto  = (UserDto)Session[Constants.SKCURRENTUSER];

                    labourchargedto.LabourCharge = model.LabourCharge;
                    labourchargedto.CAId         = Convert.ToInt32(Helper.GetCAIdOfUser(currentUserDto));
                    labourchargedto.CreatedBy    = currentUserDto.UserId;
                    labourchargedto.ModifiedBy   = currentUserDto.UserId;



                    if (FormMode == "edit")
                    {
                        labourchargedto.LabourChargeId = Id;
                        labourchargedto = LCTClient.Update(labourchargedto, currentUserDto.UserName);
                    }
                    else
                    {
                        labourchargedto.CreatedBy = currentUserDto.UserId;
                        labourchargedto           = LCTClient.Create(labourchargedto, currentUserDto.UserName);
                    }

                    if (labourchargedto.Response.HasWarning)
                    {
                        int i = 0;
                        foreach (BusinessWarning bw in labourchargedto.Response.BusinessWarnings)
                        {
                            if (bw.Message == Constants.BRLABOURCHARGEVALIDATION)
                            {
                                ModelState.AddModelError("err" + (++i).ToString(), ErrorAndValidationMessages.BRLabourChargeValidation);
                            }
                        }
                    }
                    else
                    {
                        if (FormMode == "edit")
                        {
                            TempData["LabourChargeSaved"] = ClientResources.AddLCTUpdated;
                        }
                        else
                        {
                            TempData["LabourChargeSaved"] = ClientResources.AddLCTSaved;
                        }
                        FormMode = string.Empty;
                        return(RedirectToAction("LabourChargeTypesListIndex", "ClientMasters"));
                    }
                }
            }
            catch (Exception ex)
            {
                return(View("ErrorPage"));
            }
            finally
            {
                if (LCTClient != null)
                {
                    LCTClient.Close();
                }
            }
            //model.ChargesPayableToList = GetChargesPayableTo();
            return(View(model));
        }
Beispiel #7
0
 public LabourChargeTypeDto Create(LabourChargeTypeDto labourchargetypedto, string userName)
 {
     return(ExecuteCommand(() => Service.Create(labourchargetypedto, userName)));
 }