Ejemplo n.º 1
0
        public async Task <IActionResult> UpSertEmployeeDetail(EmployeeDetail model)
        {
            if (model.Id > 0)
            {
                var updateModel    = CommanCRUDHelper.CommanUpdateCode(model, 1);
                var updateResponse = await _IEmployeeDetailService.Update(updateModel);

                return(Json(ResponseHelper.GetResponseMessage(updateResponse)));
            }
            var createModel    = CommanCRUDHelper.CommanCreateCode(model, 1);
            var createResponse = await _IEmployeeDetailService.CreateEntity(createModel);

            return(Json(ResponseHelper.GetResponseMessage(createResponse)));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> UpSertCustomer(CustomerMaster modelEntity)
        {
            if (modelEntity.Id == 0)
            {
                var createHelperModel = CommanCRUDHelper.CommanCreateCode(modelEntity, 1);
                var createResponse    = await _ICustomerMasterService.CreateEntity(createHelperModel);

                return(Json(ResponseHelper.GetResponseMessage(createResponse)));
            }
            var updateHelperModel = CommanCRUDHelper.CommanUpdateCode(modelEntity, 1);
            var updateResponse    = await _ICustomerMasterService.Update(updateHelperModel);

            return(Json(ResponseHelper.GetResponseMessage(updateResponse)));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> UpSertUserDetail(UserDetail modelEntity)
        {
            if (modelEntity.Id > 0)
            {
                var updateModel    = CommanCRUDHelper.CommanUpdateCode(modelEntity, 1);
                var updateResponse = await _IUserDetailService.Update(updateModel);

                return(Json(ResponseHelper.GetResponseMessage(updateResponse)));
            }
            var createModel    = CommanCRUDHelper.CommanCreateCode(modelEntity, 1);
            var createReposnse = await _IUserDetailService.Update(createModel);

            return(Json(ResponseHelper.GetResponseMessage(createReposnse)));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> UpsertDetail(IGL.Core.Entities.Organization.Organisation modelEntity)
        {
            if (modelEntity.Id == 0)
            {
                var createModel = CommanCRUDHelper.CommanCreateCode(modelEntity, 1);
                var response    = await _IOrganisationService.CreateEntity(createModel);

                return(Json(ResponseHelper.GetResponseMessage(response)));
            }
            var updateModel    = CommanCRUDHelper.CommanUpdateCode(modelEntity, 1);
            var updateResponse = await _IOrganisationService.Update(updateModel);

            return(Json(ResponseHelper.GetResponseMessage(updateResponse)));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> UpSertVendor(VendorMaster model)
        {
            if (model.Id == 0)
            {
                var createModel = CommanCRUDHelper.CommanCreateCode(model, 1);
                var response    = await _IVendorMasterService.CreateEntity(createModel);

                return(Json(ResponseHelper.GetResponseMessage(response)));
            }

            var updateModel   = CommanCRUDHelper.CommanUpdateCode(model, 1);
            var updateRespose = await _IVendorMasterService.Update(updateModel);

            return(Json(ResponseHelper.GetResponseMessage(updateRespose)));
        }
Ejemplo n.º 6
0
        public async Task<IActionResult> UpSertMaterial(MaterialMaster model)
        {
            if (model.Id == 0)
            {
                var createModel = CommanCRUDHelper.CommanCreateCode(model, 1);
                var createResponse = await _IMaterialMasterService.CreateEntity(createModel);

                var createdPrdctId = (await _IMaterialMasterService.GetList(x => x.IsActive == 1)).Max(x => x.Id);
                var rateMasterResponse = await UpdateRateMaster(createdPrdctId, model.PerUnitCost);

                return Json(ResponseHelper.GetResponseMessage(createResponse));
            }
            else
            {
                var updateModel = CommanCRUDHelper.CommanUpdateCode(model, 1);
                var updateResponse = await _IMaterialMasterService.Update(updateModel);

                var rateMasterResponse = await UpdateRateMaster(model.Id, model.PerUnitCost);

                return Json(ResponseHelper.GetResponseMessage(updateResponse));
            }


        }
Ejemplo n.º 7
0
        public async Task <IActionResult> CreateSIVDetail(SIVDetail model, string[] matId, string[] unitPrice, string[] qty, string[] Remarks, string Save)
        {
            if (Save.ToLower().Trim() == "save")
            {
                var createHelper   = CommanCRUDHelper.CommanCreateCode(model, 1);
                var createResponse = await _ISIVDetailService.CreateEntity(createHelper);

                var purchasedetail = await _IPoDetailService.GetSingle(x => x.Id == model.PoId);

                purchasedetail.POStatus = "SIVCreated";
                var updatePo = await _IPoDetailService.Update(purchasedetail);

                if (createResponse == ResponseMessage.AddedSuccessfully)
                {
                    var SIVDetails = await _ISIVDetailService.GetList(x => x.IsActive == 1);

                    List <SIVMaterialTransaction> models = new List <SIVMaterialTransaction>();
                    for (int i = 0; i < matId.Count(); i++)
                    {
                        SIVMaterialTransaction itemData = new SIVMaterialTransaction();
                        itemData.ItemId     = Convert.ToInt32(matId[i]);
                        itemData.UnitPrice  = Convert.ToDecimal(unitPrice[i]);
                        itemData.Quantity   = Convert.ToInt32(qty[i]);
                        itemData.ItemNumber = string.Empty;
                        itemData.SIVId      = SIVDetails.Max(x => x.Id);
                        models.Add(itemData);
                    }

                    var createSIVItemResponse = await _ISIVTransactionService.Add(models.ToArray());

                    return(Json(ResponseHelper.GetResponseMessage(createSIVItemResponse)));
                }
            }
            else
            {
                var purchasedetail = await _IPoDetailService.GetSingle(x => x.Id == model.PoId);

                purchasedetail.POStatus = "SIVApproved";
                var updatePo = await _IPoDetailService.Update(purchasedetail);

                var sivDetail = await _ISIVDetailService.GetSingle(x => x.PoId == model.PoId && x.IsActive == 1);

                sivDetail.InvoiceDate   = model.InvoiceDate;
                sivDetail.InvoiceNumber = model.InvoiceNumber;
                sivDetail.InvoicePath   = model.InvoicePath;
                sivDetail.StoreId       = model.StoreId;
                var updateSivModelHelper = CommanCRUDHelper.CommanUpdateCode(sivDetail, 1);
                var updateSIVResponse    = await _ISIVDetailService.Update(updateSivModelHelper);

                if (updateSIVResponse == ResponseMessage.UpdatedSuccessfully)
                {
                    var sivItemDetails = await _ISIVTransactionService.GetList(x => x.SIVId == sivDetail.Id && x.IsActive == 1);

                    sivItemDetails.ToList().ForEach(item =>
                    {
                        item.IsActive    = 0;
                        item.IsDeleted   = 1;
                        item.UpdatedDate = DateTime.Now.Date;
                        item.UpdatedBy   = 1;
                    });

                    var deleteResponse = await _ISIVTransactionService.Update(sivItemDetails.ToArray());

                    if (deleteResponse == ResponseMessage.UpdatedSuccessfully)
                    {
                        List <SIVMaterialTransaction> models = new List <SIVMaterialTransaction>();
                        for (int i = 0; i < matId.Count(); i++)
                        {
                            SIVMaterialTransaction itemData = new SIVMaterialTransaction();
                            itemData.ItemId     = Convert.ToInt32(matId[i]);
                            itemData.UnitPrice  = Convert.ToDecimal(unitPrice[i]);
                            itemData.Quantity   = Convert.ToInt32(qty[i]);
                            itemData.ItemNumber = string.Empty;
                            itemData.SIVId      = sivDetail.Id;
                            models.Add(itemData);
                        }

                        var createSIVItemResponse = await _ISIVTransactionService.Add(models.ToArray());

                        var responseUpdate = await UpdateProductOnSIVApprove(matId, qty, unitPrice);

                        var updateRateMaster = await UpdateRateMaster(matId, unitPrice);

                        return(Json(ResponseHelper.GetResponseMessage(createSIVItemResponse)));
                    }
                }
            }
            return(Json("There is somethng wents wrong. Please contact Admin Team."));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> CreatePurchaseOrder(PurchaseOrder model, string[] matId, string[] remarks, string[] qty, string[] unitPrice, int poId)
        {
            //if po already exists then Approve the po
            if ((await _IPurchaseOrderService.GetList(x => x.IsActive == 1 && x.Id == poId)).Count() > 0)
            {
                var poDetail = await _IPurchaseOrderService.GetSingle(x => x.Id == poId);

                poDetail.POStatus = "POApproved";
                await _IPurchaseOrderService.Update(poDetail);

                var poItems = await _IPOItemService.GetList(x => x.PoId == poDetail.Id);

                poItems.ToList().ForEach(item => {
                    item.IsActive    = 0;
                    item.IsDeleted   = 1;
                    item.UpdatedBy   = 1;
                    item.UpdatedDate = DateTime.Now.Date;
                });
                var deletePreviousPoItems = await _IPOItemService.Update(poItems.ToArray());

                List <POItem> tempPOItems = new List <POItem>();

                for (int i = 0; i < matId.Count(); i++)
                {
                    POItem item = new POItem();
                    item.PoId        = poDetail.Id;
                    item.ItemId      = Convert.ToInt32(matId[i]);
                    item.Quantity    = Convert.ToInt32(qty[i]);
                    item.Amount      = Convert.ToDecimal(Convert.ToInt32(qty[i]) * Convert.ToDecimal(unitPrice[i]));
                    item.Remarks     = remarks[i];
                    item.IsActive    = 1;
                    item.IsDeleted   = 0;
                    item.CreatedBy   = 1;
                    item.CreatedDate = DateTime.Now.Date;
                    tempPOItems.Add(item);
                }

                var itemResponse = await _IPOItemService.Add(tempPOItems.ToArray());

                return(Json(ResponseHelper.GetResponseMessage(itemResponse)));
            }
            else
            {
                var createHelper = CommanCRUDHelper.CommanCreateCode(model, 1);
                createHelper.POStatus = "Created";
                var response = await _IPurchaseOrderService.CreateEntity(model);

                var tempPoId = (await _IPurchaseOrderService.GetList(x => x.IsActive == 1)).Max(x => x.Id);

                List <POItem> poItems = new List <POItem>();

                for (int i = 0; i < matId.Count(); i++)
                {
                    POItem item = new POItem();
                    item.PoId        = tempPoId;
                    item.ItemId      = Convert.ToInt32(matId[i]);
                    item.Quantity    = Convert.ToInt32(qty[i]);
                    item.Amount      = Convert.ToDecimal(Convert.ToInt32(qty[i]) * Convert.ToDecimal(unitPrice[i]));
                    item.Remarks     = remarks[i];
                    item.IsActive    = 1;
                    item.IsDeleted   = 0;
                    item.CreatedBy   = 1;
                    item.CreatedDate = DateTime.Now.Date;
                    poItems.Add(item);
                }

                var itemResponse = await _IPOItemService.Add(poItems.ToArray());

                return(Json(ResponseHelper.GetResponseMessage(itemResponse)));
            }
        }