示例#1
0
        public async Task <ActionResult> DeleteVarianceMaster(VarianceMasterViewModel varianceMaster)
        {
            string result = string.Empty;

            VarianceMasterViewModel varianceModel = new VarianceMasterViewModel()
            {
                VarianceId          = varianceMaster.VarianceId,
                MainActivityId      = varianceMaster.MainActivityId,
                VarianceName        = varianceMaster.VarianceName,
                VarianceCode        = varianceMaster.VarianceCode,
                OrgId               = 1,
                ParentId            = 1,
                Sequence            = varianceMaster.Sequence,
                Status              = varianceMaster.Status,
                IsDeleted           = true,
                VarianceDescription = varianceMaster.VarianceDescription
            };


            var objSaveVarianceMaster = await _varianceMasterHelper.UpdateActivityMasterDetails(varianceModel);

            if (objSaveVarianceMaster.VarianceId > 0)
            {
                varianceMaster.Success = true;
                varianceMaster.Message = "Variance master deleted successfully!!!!!";
            }
            else
            {
                varianceMaster.Success = false;
                varianceMaster.Message = "Variance master did not  saved successfully!!!!!";
            }
            return(Json(varianceMaster));
        }
        public async Task <VarianceMasterViewModel> SaveVarianceMasterDetails(VarianceMasterViewModel varianceMasterViewModel)
        {
            VarianceMaster variance = new VarianceMaster()
            {
                Variance_Id         = varianceMasterViewModel.VarianceId,
                Variance_Name       = varianceMasterViewModel.VarianceName,
                Variance_Code       = varianceMasterViewModel.VarianceCode,
                Parent_Id           = varianceMasterViewModel.ParentId,
                Org_Id              = varianceMasterViewModel.OrgId,
                Status              = varianceMasterViewModel.Status,
                Sequence            = varianceMasterViewModel.Sequence,
                Is_Deleted          = varianceMasterViewModel.IsDeleted,
                VarianceDescription = varianceMasterViewModel.VarianceDescription,
                Main_Activity_Id    = varianceMasterViewModel.MainActivityId,
                Created_By          = "aaaa",
                Modified_By         = "aaa",
                Created_Date        = DateTime.Today,
                Modified_Date       = DateTime.Today
            };

            var varianceMaster = await _varianceMasterDetailsHelper.CreateAsync(variance);

            VarianceMasterViewModel varianceMastersViewModel = new VarianceMasterViewModel()
            {
                VarianceId = varianceMaster.Variance_Id
            };

            return(varianceMastersViewModel);
        }
示例#3
0
        public async Task <IActionResult> SaveVarianceMaster(int varianceId = 0)
        {
            var mainActivityMasters = await _mainActivityMasterHelper.GetAllMainActivityMasterDetails();

            List <MainActivityMasterViewModel> lstMainActivityMaster = new List <MainActivityMasterViewModel>();
            VarianceMasterViewModel            variMasterModel       = new VarianceMasterViewModel();

            if (mainActivityMasters != null)
            {
                foreach (var item in mainActivityMasters)
                {
                    lstMainActivityMaster.Add(new MainActivityMasterViewModel()
                    {
                        MainActivityId   = item.MainActivityId,
                        MainActivityCode = item.MainActivityCode
                    });
                }
            }

            if (varianceId > 0)
            {
                var varianceMasterList = await _varianceMasterHelper.GetAllVarianceMasterDetails("", varianceId, 1);

                if (varianceMasterList != null)
                {
                    variMasterModel.VarianceId          = varianceMasterList[0].VarianceId;
                    variMasterModel.MainActivityId      = varianceMasterList[0].MainActivityId;
                    variMasterModel.VarianceName        = varianceMasterList[0].VarianceName;
                    variMasterModel.VarianceCode        = varianceMasterList[0].VarianceCode;
                    variMasterModel.ParentId            = varianceMasterList[0].ParentId;
                    variMasterModel.OrgId               = varianceMasterList[0].OrgId;
                    variMasterModel.Status              = varianceMasterList[0].Status;
                    variMasterModel.Sequence            = varianceMasterList[0].Sequence;
                    variMasterModel.IsDeleted           = varianceMasterList[0].IsDeleted;
                    variMasterModel.VarianceDescription = varianceMasterList[0].VarianceDescription;
                }
            }
            variMasterModel.lstMainActivityMaster = lstMainActivityMaster;

            return(PartialView("SaveVarianceMaster", variMasterModel));
        }
示例#4
0
        public async Task <IActionResult> SaveVarianceMaster(VarianceMasterViewModel varianceMaster)
        {
            try
            {
                VarianceMasterViewModel varianceModel = new VarianceMasterViewModel()
                {
                    VarianceId          = varianceMaster.VarianceId,
                    MainActivityId      = varianceMaster.MainActivityId,
                    VarianceName        = varianceMaster.VarianceName,
                    VarianceCode        = varianceMaster.VarianceCode,
                    OrgId               = 1,
                    ParentId            = 1,
                    Sequence            = varianceMaster.Sequence,
                    Status              = varianceMaster.Status,
                    IsDeleted           = false,
                    VarianceDescription = varianceMaster.VarianceDescription
                };
                #region validaate group code
                var varianceMasterList = await _varianceMasterHelper.GetAllVarianceMasterDetails(varianceMaster.VarianceCode);

                #endregion

                if (varianceModel.VarianceId == 0)
                {
                    if (varianceMasterList?.Count == 0)
                    {
                        var objSaveVarianceMaster = await _varianceMasterHelper.SaveVarianceMasterDetails(varianceModel);

                        if (objSaveVarianceMaster.VarianceId > 0)
                        {
                            varianceMaster.Success = true;
                            varianceMaster.Message = "Variance master saved successfully!!!!!";
                        }
                    }
                    else
                    {
                        varianceMaster.Success = false;
                        varianceMaster.Message = "Variance master code already exists!!!";
                    }
                }
                else
                {
                    if (varianceMasterList?.Count < 2)
                    {
                        var objSaveActivityMaster = await _varianceMasterHelper.UpdateActivityMasterDetails(varianceModel);

                        if (objSaveActivityMaster.VarianceId > 0)
                        {
                            varianceMaster.Success = true;
                            varianceMaster.Message = "Variance master saved successfully!!!!!";
                        }
                    }
                    else
                    {
                        varianceMaster.Success = false;
                        varianceMaster.Message = "Variance master code already exists for other items!!!";
                    }
                }
            }
            catch (Exception ex)
            {
                varianceMaster.Success = false;
                varianceMaster.Message = "Main  activity master did not saved successfully!!!!";
            }

            return(Json(varianceMaster));
        }