예제 #1
0
        public JobRequestAttachmentMain GetJobFileAttachmentObjects(Guid id)
        {
            JobRequestAttachmentMain obj = new JobRequestAttachmentMain();

            try
            {
                obj.RequestObj = db.JobRequest.Find(id);
                var temp = from x in db.JobRequestAttachments
                           where x.RequestKey == id

                           select new JobRequestAttachmentsObject
                {
                    PKey            = x.PKey,
                    RequestKey      = x.RequestKey,
                    DocumentTypeKey = x.DocumentTypeKey,
                    DocFile         = x.DocFile,
                    Filename        = x.Filename,
                    FileType        = x.FileType,
                    DocumentName    = x.DocumentType.TName
                };
                obj.JobRequestAttachmentsList = new List <JobRequestAttachmentsObject>();
                obj.JobRequestAttachmentsList = temp.ToList();
            }
            catch (Exception ex)
            {
                string fall = ex.ToString();
            }
            return(obj);
        }
예제 #2
0
        public ActionResult Index(HttpPostedFileBase file, JobRequestAttachmentMain model)
        {
            if (GlobalClass.SystemSession)
            {
                ViewBag.mess             = "";
                model.fileObj            = new JobRequestAttachmentsObject();
                model.fileObj.RequestKey = model.RequestObj.RequestKey;
                if (ModelState.IsValid)
                {
                    if (file != null)
                    {
                        byte[] data = null;
                        using (Stream inputStream = file.InputStream)
                        {
                            MemoryStream memoryStream = inputStream as MemoryStream;
                            if (memoryStream == null)
                            {
                                memoryStream = new MemoryStream();
                                inputStream.CopyTo(memoryStream);
                            }
                            data = memoryStream.ToArray();
                        }
                        model.fileObj.FileType = file.ContentType;
                        model.fileObj.Filename = file.FileName;
                        model.fileObj.DocFile  = data;
                        DataReturn dt = setup.SaveAttachmentInRequest(model);
                        ViewBag.mess = dt.mess;
                    }
                }


                model = setup.GetJobFileAttachmentObjects(model.RequestObj.RequestKey);

                ViewBag.DocumentTypeKey = new SelectList(db.DocumentType.Where(m => m.DocumentForID == 6 && m.IsDelete == false && m.CompanyKey == GlobalClass.Company.CompanyKey).OrderBy(m => m.TName), "ID", "TName");

                return(View(model));
            }
            else
            {
                Exception e = new Exception("Sorry, your Session has Expired");
                return(View("Error", new HandleErrorInfo(e, "Home", "Logout")));
            }
        }
예제 #3
0
        // GET: JobRequestFile
        public ActionResult Index(Guid id)
        {
            if (GlobalClass.SystemSession)
            {
                JobRequestAttachmentMain model = new JobRequestAttachmentMain();

                ViewBag.mess = " ";

                model = setup.GetJobFileAttachmentObjects(id);

                ViewBag.DocumentTypeKey = new SelectList(db.DocumentType.Where(m => m.DocumentForID == 6 && m.IsDelete == false && m.CompanyKey == GlobalClass.Company.CompanyKey).OrderBy(m => m.TName), "ID", "TName");

                return(View(model));
            }
            else
            {
                Exception e = new Exception("Sorry, your Session has Expired");
                return(View("Error", new HandleErrorInfo(e, "Home", "Logout")));
            }
        }
예제 #4
0
        public DataReturn SaveAttachmentInRequest(JobRequestAttachmentMain model)
        {
            DataReturn obj = new DataReturn();

            try
            {
                JobRequestAttachments fj = db.JobRequestAttachments.SingleOrDefault(m => m.RequestKey == model.RequestObj.RequestKey && m.DocumentTypeKey == model.DocumentTypeKey);
                if (fj == null)
                {
                }
                else
                {
                    db.JobRequestAttachments.Remove(fj);
                    db.SaveChanges();
                    db = new RCSdbEntities();
                }
                JobRequestAttachments invoice = new JobRequestAttachments();

                invoice.PKey            = Guid.NewGuid();
                invoice.RequestKey      = (Guid)model.RequestObj.RequestKey;
                invoice.DocumentTypeKey = model.DocumentTypeKey;

                invoice.DocFile  = model.fileObj.DocFile;
                invoice.Filename = model.fileObj.Filename;
                invoice.FileType = model.fileObj.FileType;


                db.JobRequestAttachments.Add(invoice);
                db.SaveChanges();

                obj.flag = 1;
                obj.mess = "Data has been updated successfully.";
            }
            catch (Exception ex)
            {
                obj.mess = ex.ToString();
                obj.flag = 0;
            }
            obj.key = model.RequestObj.RequestKey;
            return(obj);
        }