Пример #1
0
        public async Task <IActionResult> PutSamplingworkFTMain([FromQuery] SamplingworkFTMain samplingworkFTMain)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                var updateData = _context.SamplingworkFTMain.Where(x => x.RAppraisalID == samplingworkFTMain.RAppraisalID).FirstOrDefault();
                if (updateData == null)
                {
                    return(NotFound(EnumMessage.StatusMessage.Error.NotFoundUpdate));
                }
                else
                {
                    updateData.AppraisalID          = samplingworkFTMain.AppraisalID;
                    updateData.ProjectName          = samplingworkFTMain.ProjectName;
                    updateData.ProjectCode          = samplingworkFTMain.ProjectCode;
                    updateData.MonthCheck           = samplingworkFTMain.MonthCheck;
                    updateData.YearCheck            = samplingworkFTMain.YearCheck;
                    updateData.BankDateCheck        = samplingworkFTMain.BankDateCheck;
                    updateData.SubCategory          = samplingworkFTMain.SubCategory;
                    updateData.Landplot             = samplingworkFTMain.Landplot;
                    updateData.RoomPlan             = samplingworkFTMain.RoomPlan;
                    updateData.ProjPlan             = samplingworkFTMain.ProjPlan;
                    updateData.House_Roomno         = samplingworkFTMain.House_Roomno;
                    updateData.Pictures             = samplingworkFTMain.Pictures;
                    updateData.OtherDocument        = samplingworkFTMain.OtherDocument;
                    updateData.AppraisalBankid      = samplingworkFTMain.AppraisalBankid;
                    updateData.AppraisalDate        = samplingworkFTMain.AppraisalDate;
                    updateData.ChkReportBankid      = samplingworkFTMain.ChkReportBankid;
                    updateData.ChkReportdate        = samplingworkFTMain.ChkReportdate;
                    updateData.AssistantAppDirector = samplingworkFTMain.AssistantAppDirector;
                    updateData.AssistDate           = samplingworkFTMain.AssistDate;
                    _context.Update(updateData);
                    await _context.SaveChangesAsync();

                    return(Ok(EnumMessage.StatusMessage.Success.DataSaveChange));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Пример #2
0
        public async Task <IActionResult> PostSamplingworkFTMain([FromForm] SamplingworkFTMainPOstModel samplingworkFTMain)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }


                var insertData = new SamplingworkFTMain()
                {
                    AppraisalID          = samplingworkFTMain.AppraisalID,
                    ProjectName          = samplingworkFTMain.ProjectName,
                    ProjectCode          = samplingworkFTMain.ProjectCode,
                    MonthCheck           = samplingworkFTMain.MonthCheck,
                    YearCheck            = samplingworkFTMain.YearCheck,
                    BankDateCheck        = samplingworkFTMain.BankDateCheck,
                    SubCategory          = samplingworkFTMain.SubCategory,
                    Landplot             = samplingworkFTMain.Landplot,
                    RoomPlan             = samplingworkFTMain.RoomPlan,
                    ProjPlan             = samplingworkFTMain.ProjPlan,
                    House_Roomno         = samplingworkFTMain.House_Roomno,
                    Pictures             = samplingworkFTMain.Pictures,
                    OtherDocument        = samplingworkFTMain.OtherDocument,
                    AppraisalBankid      = samplingworkFTMain.AppraisalBankid,
                    AppraisalDate        = samplingworkFTMain.AppraisalDate,
                    ChkReportBankid      = samplingworkFTMain.ChkReportBankid,
                    ChkReportdate        = samplingworkFTMain.ChkReportdate,
                    AssistantAppDirector = samplingworkFTMain.AssistantAppDirector,
                    AssistDate           = samplingworkFTMain.AssistDate,
                };

                #region :: genPK ::
                using (SqlConnection sqlConnection = new SqlConnection(EnumMessage.connectionString.connect))
                {
                    sqlConnection.Open();
                    SqlCommand sql = new SqlCommand(" SELECT NEXT VALUE FOR  dbo.RAppraisalInfo_SEQ", sqlConnection);

                    using (SqlDataReader reader = sql.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            insertData.RAppraisalID = reader.GetInt64(0);
                        }
                    }
                    sqlConnection.Close();
                }
                #endregion


                _context.SamplingworkFTMain.Add(insertData);
                await _context.SaveChangesAsync();

                return(Ok(EnumMessage.StatusMessage.Success.DataSaved));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }