public ActionResult EditProjectCosting(ProjectCostingViewModel projectInfo)
        {
            var userId = Request.Cookies["auth.id"].Value;

            projectInfo.EditedBy = Convert.ToInt32(userId);
            projectInfo.EditedOn = DateTime.Now;
            try
            {
                if (!string.IsNullOrWhiteSpace(projectInfo.InvoiceDateText))
                {
                    projectInfo.InvoiceDate = Convert.ToDateTime(projectInfo.InvoiceDateText);
                }
            }
            catch (Exception ex)
            {
                return(Json(new { status = false, message = "FTP Upload Date format is incorrect." }));
            }


            var result = projectModel.EditProjectCostingInfo(projectInfo);

            if (result == 0)
            {
                return(Json(new { status = true, message = "Project costing is updated successfully." }));
            }
            else if (result == 1)
            {
                return(Json(new { status = false, message = "Please enter all required values." }));
            }
            else
            {
                return(Json(new { status = false, message = "Project costing is not updated successfully." }));
            }
        }
Example #2
0
        internal int EditProjectCostingInfo(ProjectCostingViewModel model)
        {
            if (model != null)
            {
                var project = db.Projects.Where(x => x.Id == model.ProjectId).FirstOrDefault();
                if (project == null)
                {
                    return(1); //Data is not available in the database.
                }
                var projectCosting = db.ProjectCostings.Where(x => x.Id == model.ProjectCostingId).FirstOrDefault();

                if (projectCosting != null)
                {
                    projectCosting.CostPerRecord  = model.CostPerRecord;
                    projectCosting.Currency       = model.Currency;
                    projectCosting.InvoiceCode    = model.InvoiceCode;
                    projectCosting.InvoiceDate    = model.InvoiceDate;
                    projectCosting.InvoiceRemark  = model.InvoiceRemark;
                    projectCosting.PaymentStatus  = model.PaymentStatus;
                    projectCosting.ProjectInvoice = project.NoOfRecordsDeliverd.GetValueOrDefault() * model.CostPerRecord.GetValueOrDefault();
                    projectCosting.EditedBy       = model.EditedBy;
                    projectCosting.EditedOn       = model.EditedOn;

                    db.Entry(projectCosting).State = EntityState.Modified;
                    db.SaveChanges();
                }
                else
                {
                    projectCosting                = new ProjectCosting();
                    projectCosting.ProjectId      = model.ProjectId;
                    projectCosting.CostPerRecord  = model.CostPerRecord;
                    projectCosting.Currency       = model.Currency;
                    projectCosting.InvoiceCode    = model.InvoiceCode;
                    projectCosting.InvoiceDate    = model.InvoiceDate;
                    projectCosting.InvoiceRemark  = model.InvoiceRemark;
                    projectCosting.PaymentStatus  = model.PaymentStatus;
                    projectCosting.ProjectInvoice = project.NoOfRecordsDeliverd.GetValueOrDefault() * model.CostPerRecord.GetValueOrDefault();
                    projectCosting.EditedBy       = model.EditedBy;
                    projectCosting.EditedOn       = model.EditedOn;

                    db.ProjectCostings.Add(projectCosting);
                    db.SaveChanges();
                }

                return(0);
            }
            return(1); //Null object
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        internal ProjectCostingViewModel BindProjectCostingModel(ProjectCostingViewModel model)
        {
            if (model == null)
            {
                model = new ProjectCostingViewModel();
            }
            model.CurrencyList      = projectModel.CurrencyList();
            model.PaymentStatusList = projectModel.PaymentStatusList();
            if (model.InvoiceDate != null)
            {
                model.InvoiceDateText = model.InvoiceDate.Value.ToString("dd/MM/yyyy");
            }
            model.ProjectCostingId = model.Id;

            return(model);
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        internal ProjectDetailViewModel GetProjectById_Admin(int id)
        {
            var project     = db.Projects.Include("List.Client").Include("List").Include("Priority1").Include("ProjectStatu").Include("ProjectCostings").FirstOrDefault(x => x.Id == id);
            var projectInfo = Mapper.Map <Project, ProjectViewModel>(project);

            projectInfo.ClientId = project.List.ClientId;
            var tblProjCosting = projectInfo.ProjectCostings.FirstOrDefault();
            var projectCosting = Mapper.Map <ProjectCosting, ProjectCostingViewModel>(tblProjCosting);

            var model = new ProjectDetailViewModel();

            model.ProjectInfo = projectInfo;
            if (projectCosting == null)
            {
                projectCosting           = new ProjectCostingViewModel();
                projectCosting.ProjectId = id;
                var currency = projectCosting.Currency.GetValueOrDefault();
                projectCosting.Currency1 = db.Currencies.FirstOrDefault(x => x.Id == currency);
            }
            model.ProjectCosting = projectCosting;

            return(model);
        }