Exemplo n.º 1
0
        public BDMAppointmentReportDTO GetAppointmentReportById(BDMAppointmentReportDTO objAppointmentReport)
        {
            BDMAppointmentReportDTO appoinment = new BDMAppointmentReportDTO();

            using (DbLayer dbLayer = new DbLayer())
            {
                SqlCommand SqlCmd = new SqlCommand("spSelectBDMAppoinmentReport");
                SqlCmd.CommandType = CommandType.StoredProcedure;
                SqlCmd.Parameters.AddWithValue("@Id", objAppointmentReport.Id);
                appoinment = dbLayer.GetEntityList <BDMAppointmentReportDTO>(SqlCmd).FirstOrDefault();
            }
            return(appoinment);
        }
        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 }));
        }
Exemplo n.º 3
0
        public int InsertBDMAppointmentReport(BDMAppointmentReportDTO objAppointmentReport)
        {
            BDMAppointmentReportGetIdDTO appoinment = new BDMAppointmentReportGetIdDTO();

            {
                SqlCommand SqlCmd = new SqlCommand("spInsertBDMAppoinmentReport");
                SqlCmd.CommandType = CommandType.StoredProcedure;
                SqlCmd.Parameters.AddWithValue("@ClientId", objAppointmentReport.ClientId);
                SqlCmd.Parameters.AddWithValue("@Date", objAppointmentReport.Date);
                SqlCmd.Parameters.AddWithValue("@Calltype", objAppointmentReport.Calltype);
                SqlCmd.Parameters.AddWithValue("@Remarks", objAppointmentReport.Remarks);
                SqlCmd.Parameters.AddWithValue("@CreatedBy", objAppointmentReport.CreatedBy);
                appoinment = new DbLayer().GetEntityList <BDMAppointmentReportGetIdDTO>(SqlCmd).FirstOrDefault();
            }
            if (appoinment != null)
            {
                return(appoinment.Id);
            }
            else
            {
                return(-1);
            }
        }