Esempio n. 1
0
        public ActionResult ExpertAdd(ExpertVM model, IEnumerable<HttpPostedFileBase> file)
        {

            ContactService _contactService = new ContactService();
            string physicalPath = " ~/Areas/Ofiice/image/";
            int maxFileSize = 500000;

            Expert expert;

            Dictionary<FileResultItem, FileResultType> resultModel = FileDocumentUpload(file, maxFileSize, physicalPath, new string[] { "image/gif", "image/png", "image/jpeg", "image/pjpeg", "image/bmp", "image/x-png", "image/jpg" });

            foreach (var item in resultModel)
            {
                if (item.Value == FileResultType.Error || item.Value == FileResultType.NoneFile || item.Value == FileResultType.SizeOver || item.Value == FileResultType.WrongType)
                {
                    RemoveAll(resultModel.Keys, physicalPath);
                    TempData["NoteCss"] = "warning";
                    TempData["NoteText"] = ControlMessages(item.Value, maxFileSize).Keys.FirstOrDefault().ToString();

                    return View("ExpertAdd");
                }
            }

            expert = new Expert();
            foreach (var item in resultModel.Keys)
            {
                try
                {
                expert.PhotoURL = item.UploadPath;
                expert.Name = model.Expert.Name;
                expert.Surname = model.Expert.Surname;
                expert.Profession = model.Expert.Profession;
                expert.WagePolicy = model.Expert.WagePolicy;
                expert.Note = model.Expert.Note;
                expert.BirthDate = model.Expert.BirthDate;
                expert.CompanyID =Convert.ToInt32(AccountController._compID);
                _expertService.AddExpert(expert);
                _contactService.AddContact(new Contact { ExpertID = expert.ExpertID, Address = model.Contact.Address, PhoneNumber1 = model.Contact.PhoneNumber1, PhoneNumber2 = model.Contact.PhoneNumber2, IsActive = true, Email = model.Contact.Email });
                    ViewBag.Mesaj = "Uzman Başarıyla Eklendi";

                }
                catch (Exception)
                {

                    throw;
                }  
            }
            return View("ExpertAdd");
        }
Esempio n. 2
0
 // POST api/expert
 public string Post([FromBody] Expert expert)
 {
     return(_expertService.AddExpert(expert));
 }