예제 #1
0
        public async Task <CommonResponse> ChangePositionKeepAs(ChangePositionKeepReq request)
        {
            CommonResponse response = new CommonResponse();

            try
            {
                mGuesstimate guesstimate;
                guesstimate = _MongoContext.mGuesstimate.AsQueryable().Where(a => a.QRFID == request.QRFID && a.IsCurrentVersion == true).OrderByDescending(b => b.VersionId).FirstOrDefault();

                guesstimate.EditUser = request.EditUser;
                guesstimate.EditDate = DateTime.Now;

                foreach (var pos in guesstimate.GuesstimatePosition)
                {
                    if (request.PositionIds.Contains(pos.PositionId))
                    {
                        pos.KeepAs = request.ChangeType;
                    }
                }

                ReplaceOneResult replaceResult = await _MongoContext.mGuesstimate.ReplaceOneAsync(Builders <mGuesstimate> .Filter.Eq("GuesstimateId", guesstimate.GuesstimateId), guesstimate);

                response.Id = await _qRFSummaryRepository.SaveQRFPrice("Commercial", "Position Keep As changed", request.QRFID, request.EditUser);

                response.ResponseStatus.Status       = replaceResult.MatchedCount > 0 ? "Success" : "Failure";
                response.ResponseStatus.ErrorMessage = replaceResult.MatchedCount > 0 ? "Saved Successfully." : "Details not updated.";
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                response.ResponseStatus.Status       = "Failure";
                response.ResponseStatus.ErrorMessage = ex.Message;
            }
            return(response);
        }
예제 #2
0
        public async Task <CostsheetVerSetRes> SetCostsheetNewVersion([FromBody] CostsheetVerSetReq request)
        {
            var response = new CostsheetVerSetRes();

            try
            {
                if (!string.IsNullOrEmpty(request.QRFID) && request != null)
                {
                    if (request.Pipeline == "Guesstimate")
                    {
                        response.QRFPrice_Id = await _qRFSummaryRepository.SaveQRFPrice("Guesstimate", "Regenerated from Guesstimate", request.QRFID, request.Create_User);

                        response.ResponseStatus.Status       = !String.IsNullOrEmpty(response.QRFPrice_Id) ? "Success" : "Failure";
                        response.ResponseStatus.ErrorMessage = !String.IsNullOrEmpty(response.QRFPrice_Id) ? "Costsheet Data Saved Successfully." : "Details not updated.";
                    }
                    else if (request.Pipeline == "Amendment")
                    {
                        await _qRFSummaryRepository.SaveDefaultGuesstimate(request.QRFID, "Amendment", "Regenerated from Amendment", request.Create_User);

                        response.QRFPrice_Id = await _qRFSummaryRepository.SaveQRFPrice("Amendment", "Regenerated from Amendment", request.QRFID, request.Create_User);

                        await _qRFSummaryRepository.SaveDefaultItinerary(request.Create_User, request.QRFID, "", true);

                        response.ResponseStatus.Status       = !String.IsNullOrEmpty(response.QRFPrice_Id) ? "Success" : "Failure";
                        response.ResponseStatus.ErrorMessage = !String.IsNullOrEmpty(response.QRFPrice_Id) ? "Costsheet Data Saved Successfully." : "Details not updated.";
                    }
                }
                else
                {
                    response.ResponseStatus.Status       = "Failure";
                    response.ResponseStatus.ErrorMessage = "QRFId can not be Null/Zero.";
                }
            }
            catch (Exception ex)
            {
                response.ResponseStatus.Status       = "Failure";
                response.ResponseStatus.ErrorMessage = "An Error Occurs :- " + ex.Message;
            }

            return(response);
        }