public object RunRequest(AddFeasibilityRequest request)
        {
            var resp   = new AddFeasibilityResponse();
            var LeadId = request.Feasibility.FirstOrDefault().LeadId;
            var Lead   = _dbContext.Lead.Where(x => x.Id == LeadId).FirstOrDefault();

            Lead.PmdStatus = request.Status;
            if (Lead.PmdStatus == (int)PmdStatus.NotFeasible)
            {
                Lead.LeadStatus = (int)LeadStatus.Cancelled;
            }
            Lead.PmdRemarks = request.PmdRemarks;
            var LeadStatusResult = _dbContext.SaveChanges();

            foreach (var feasibility in request.Feasibility)
            {
                var Feasibility = new PmdDetails();
                Feasibility.LeadId           = feasibility.LeadId;
                Feasibility.Bandwidth        = feasibility.Bandwidth;
                Feasibility.OTC              = feasibility.OTC;
                Feasibility.MRC              = feasibility.MRC;
                Feasibility.VendorId         = feasibility.VendorId;
                Feasibility.Remarks          = feasibility.Remarks;
                Feasibility.CreatedAt        = DateTime.Now;
                Feasibility.CreatedBy        = request.CreatedBy;
                Feasibility.ConnectivityType = feasibility.ConnectivityType;
                _dbContext.PmdDetails.Add(Feasibility);
                var Result = _dbContext.SaveChanges();
            }
            return(resp);
        }
Exemple #2
0
        public object RunRequest(EditFeasibilityRequest request)
        {
            var resp   = new EditFeasibilityResponse();
            var LeadId = request.Feasibility.FirstOrDefault().LeadId;

            var Lead = _dbContext.Lead.Where(x => x.Id == LeadId).FirstOrDefault();

            Lead.PmdStatus = request.Status;
            if (Lead.PmdStatus == (int)PmdStatus.NotFeasible)
            {
                Lead.LeadStatus = (int)LeadStatus.Cancelled;
            }
            Lead.PmdRemarks = request.PmdRemarks;
            var LeadStatusResult = _dbContext.SaveChanges();

            foreach (var feasibility in request.Feasibility)
            {
                if (feasibility.Id != 0)
                {
                    var Feasibility = _dbContext.PmdDetails.Where(x => x.Id == feasibility.Id).FirstOrDefault();
                    //Feasibility.LeadId = feasibility.LeadId;
                    Feasibility.Bandwidth        = feasibility.Bandwidth;
                    Feasibility.OTC              = feasibility.OTC;
                    Feasibility.MRC              = feasibility.MRC;
                    Feasibility.VendorId         = feasibility.VendorId;
                    Feasibility.Remarks          = feasibility.Remarks;
                    Feasibility.UpdatedAt        = DateTime.Now;
                    Feasibility.UpdatedBy        = request.UpdatedBy;
                    Feasibility.ConnectivityType = feasibility.ConnectivityType;
                    var Result = _dbContext.SaveChanges();
                }
                if (feasibility.Id == 0)
                {
                    var Feasibility = new PmdDetails();
                    Feasibility.LeadId           = feasibility.LeadId;
                    Feasibility.Bandwidth        = feasibility.Bandwidth;
                    Feasibility.OTC              = feasibility.OTC;
                    Feasibility.MRC              = feasibility.MRC;
                    Feasibility.VendorId         = feasibility.VendorId;
                    Feasibility.Remarks          = feasibility.Remarks;
                    Feasibility.UpdatedAt        = DateTime.Now;
                    Feasibility.UpdatedBy        = request.UpdatedBy;
                    Feasibility.ConnectivityType = feasibility.ConnectivityType;
                    _dbContext.PmdDetails.Add(Feasibility);
                    var Result = _dbContext.SaveChanges();
                }
            }



            foreach (var row in request.DeletedRows)
            {
                if (row.Id != 0)
                {
                    var PmdDetail = _dbContext.PmdDetails.Where(x => x.Id == row.Id).FirstOrDefault();
                    _dbContext.Entry(PmdDetail).State = System.Data.Entity.EntityState.Deleted;
                    _dbContext.SaveChanges();
                }
            }
            return(resp);
        }