예제 #1
0
        public ResponseOut PostRequirementUpload(PostRequirementImportViewModel data)
        {
            ResponseOut responseOut = new ResponseOut();

            using (PortalEntities _context = new PortalEntities())
            {
                try
                {
                    portal_post_requirement _requirement = new portal_post_requirement();
                    int user_id = 0;
                    if (user_id == 0)
                    {
                        user_id = _context.portal_user.Where(x => !string.IsNullOrEmpty(data.email_id) && x.email.ToLower() == data.email_id.ToLower()).Select(x => x.pk_user_id).FirstOrDefault();
                    }
                    if (user_id == 0)
                    {
                        user_id = _context.portal_user.Where(x => !string.IsNullOrEmpty(data.contact_details) && x.contact == data.contact_details).Select(x => x.pk_user_id).FirstOrDefault();
                    }
                    _requirement.mobile_no       = data.contact_details;
                    _requirement.email_id        = data.email_id;
                    _requirement.fullname        = data.client_name;
                    _requirement.added_date      = DateTime.Now;
                    _requirement.approved_status = 0;
                    if (user_id != 0)
                    {
                        _requirement.fk_client_id = user_id;
                    }
                    _requirement.subject = data.requirement_title;
                    _requirement.message = data.requirement_description;

                    _context.portal_post_requirement.Add(_requirement);
                    int result = _context.SaveChanges();
                    if (result > 0)
                    {
                        responseOut.status  = ActionStatus.Success;
                        responseOut.message = ActionMessage.RequirementPost;
                    }
                }
                catch (Exception ex)
                {
                    responseOut.status  = ActionStatus.Fail;
                    responseOut.message = ActionMessage.ApplicationException;
                }
                return(responseOut);
            }
        }
예제 #2
0
        public string ImportData(string Identifier, string type, string name)
        {
            try
            {
                string File = "";
                //name=name.Split()

                File = HttpRuntime.AppDomainAppPath + ConfigurationManager.AppSettings["FileUploadSection"].Replace('/', '\\') + name;

                DataTable dt = new DataTable();
                using (SpreadsheetDocument spreadSheetDocument = SpreadsheetDocument.Open(File, false))
                {
                    WorkbookPart        workbookPart = spreadSheetDocument.WorkbookPart;
                    IEnumerable <Sheet> sheets       = spreadSheetDocument.WorkbookPart.Workbook.GetFirstChild <Sheets>().Elements <Sheet>();
                    string relationshipId            = sheets.First().Id.Value;

                    dt.Columns.Clear();
                    dt.Rows.Clear();
                    WorksheetPart     worksheetPart = (WorksheetPart)spreadSheetDocument.WorkbookPart.GetPartById(relationshipId);
                    Worksheet         workSheet     = worksheetPart.Worksheet;
                    SheetData         sheetData     = workSheet.GetFirstChild <SheetData>();
                    IEnumerable <Row> rows          = sheetData.Descendants <Row>();

                    foreach (Cell cell in rows.ElementAt(0))
                    {
                        dt.Columns.Add(Utilities.GetCellValue(spreadSheetDocument, cell));
                    }

                    foreach (Row row in rows) //this will also include your header row...
                    {
                        DataRow tempRow     = dt.NewRow();
                        int     columnIndex = 0;
                        foreach (Cell cell in row.Descendants <Cell>())
                        {
                            // Gets the column index of the cell with data
                            int cellColumnIndex = (int)Utilities.GetColumnIndexFromName(Utilities.GetColumnName(cell.CellReference));
                            cellColumnIndex--; //zero based index
                            if (columnIndex < cellColumnIndex)
                            {
                                do
                                {
                                    tempRow[columnIndex] = ""; //Insert blank data here;
                                    columnIndex++;
                                }while (columnIndex < cellColumnIndex);
                            }
                            tempRow[columnIndex] = Utilities.GetCellValue(spreadSheetDocument, cell);

                            columnIndex++;
                        }
                        dt.Rows.Add(tempRow);
                    }
                    dt.Rows.RemoveAt(0); // Remove oth element.

                    foreach (DataRow row in dt.Rows)
                    {
                        if (type == "post_requirement")
                        {
                            var data = new PostRequirementImportViewModel
                            {
                                client_name             = row["Client Name"].ToString(),
                                contact_details         = row["contact details"].ToString(),
                                email_id                = row["email id"].ToString(),
                                engagement_model        = row["Engagement Model"].ToString(),
                                location                = row["Location"].ToString(),
                                requirement_description = row["Requirement description"].ToString(),
                                requirement_title       = row["Requirement Title"].ToString(),
                            };
                            if (data != null)
                            {
                                UploadPostRequirement(data);
                            }
                        }
                        else
                        {
                            var data = new ImportVendorCandidateViewModel
                            {
                                vendor_name                  = row["Vendor name"].ToString(),
                                vendor_user_name             = row["Vendor user name"].ToString(),
                                vendor_password              = row["Vendor Password"].ToString(),
                                candidate_firstname          = row["Candidate name"].ToString(),
                                candidate_one_liner_headline = row["one liner headline"].ToString(),
                                candidate_technology         = row["Technology"].ToString(),
                                country          = row["Country"].ToString(),
                                state            = row["State"].ToString(),
                                city             = row["City"].ToString(),
                                availability     = row["Availability (within days)"].ToString(),
                                experience_level = row["Experience level"].ToString(),
                            };
                            UploadVendorCandidate(data);
                        }

                        //AddDistributor(Identifier, null, row);
                    }
                }

                return("Success");
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
        public ResponseOut UploadPostRequirement(PostRequirementImportViewModel data)
        {
            IRequirementBL _requirement = new RequirementEngine();

            return(_requirement.PostRequirementUpload(data));
        }