コード例 #1
0
        public HttpResponseMessage CreateBDMAppointmentReport()
        {
            HttpResponseMessage message;
            var BDMAttachments = HttpContext.Current.Request.Files;
            var ClientId       = HttpContext.Current.Request.Form[0];
            var Date           = HttpContext.Current.Request.Form[1];
            var Calltype       = HttpContext.Current.Request.Form[2];
            var Remarks        = HttpContext.Current.Request.Form[3];
            var CreatedBy      = HttpContext.Current.Request.Form[4];
            BDMAppointmentReportDTO objAppointmentReport = new BDMAppointmentReportDTO();

            objAppointmentReport.ClientId  = Convert.ToInt32(ClientId);
            objAppointmentReport.Date      = Convert.ToDateTime(Date);
            objAppointmentReport.Calltype  = Convert.ToInt32(Calltype);
            objAppointmentReport.Remarks   = Remarks;
            objAppointmentReport.CreatedBy = CreatedBy;
            // BDMAppointmentReportDataAccessLayer dal=new BDMAppointmentReportDataAccessLayer();
            BDMAttachmentDTO objAttachment = new BDMAttachmentDTO();
            bool             res           = false;

            try
            {
                int id = _obj.InsertBDMAppointmentReport(objAppointmentReport);
                if (id != -1)
                {
                    SqlCommand    cmd          = new SqlCommand("Select Id from BDMAppoinmentReport where Id =" + id + "");
                    List <string> file_urlList = new List <string>();
                    for (int i = 0; i < BDMAttachments.Count; i++)
                    {
                        string fileName = id + "_" + BDMAttachments[i].FileName;
                        string path     = Path.Combine(HostingEnvironment.MapPath("~/ServeyImages"), fileName);
                        file_urlList.Add(path);
                        (BDMAttachments[i] as HttpPostedFile).SaveAs(path);
                        //  BDMAttachmentDataAccessLayer dalAttachment = new BDMAttachmentDataAccessLayer();
                        _attach.InsertBDMAttachment(new BDMAttachmentDTO
                        {
                            AppointmentId = id,
                            FileUrl       = fileName,
                        });
                    }
                    res = true;
                }
            }

            catch (Exception ex)
            {
                message = Request.CreateResponse(HttpStatusCode.BadRequest, new { msgText = "Something wrong. Try Again!" });
                ErrorLog.CreateErrorMessage(ex, "BDMAppointmentReport", "CreateBDMAppointmentReport");
            }
            return(message = Request.CreateResponse(HttpStatusCode.OK, new { msgText = "Success!", result = res }));
        }
コード例 #2
0
        public bool InsertBDMAttachment(BDMAttachmentDTO objAttachment)
        {
            bool       res    = false;
            SqlCommand SqlCmd = new SqlCommand("spInsertBDMAttachment");

            SqlCmd.CommandType = CommandType.StoredProcedure;
            SqlCmd.Parameters.AddWithValue("@AppoinmentId", objAttachment.AppointmentId);
            SqlCmd.Parameters.AddWithValue("@FileUrl", objAttachment.FileUrl);
            int result = _unitOfWork.DbLayer.ExecuteNonQuery(SqlCmd);

            if (result != Int32.MaxValue)
            {
                res = true;
            }
            return(res);
        }