示例#1
0
        public ActionResult ExpertUpdate(short id)
        {

            ExpertVM model = new ExpertVM();
            model.Expert = _expertService.FindExpert(x => x.ExpertID == id);
            model.Contact = _contactService.Find(x => x.ExpertID == id && x.IsActive == true);
            ExpCOnId = model.Contact.ContactID;

            return View(model);

        }
示例#2
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");
        }
        public ExpertDetailsForm(ExpertVM expert)
        {
            if (expert == null)
            {
                throw new ArgumentNullException(nameof(expert));
            }

            this.dbContext = new PmContext();
            InitializeComponent();
            this.BindExpertTypesDropDown(expert);

            this.currentExpertId        = expert.Id;
            this.FirstNameTextBox.Text  = expert.FirstName;
            this.MiddleNameTextBox.Text = expert.MiddleName;
            this.LastNameTextBox.Text   = expert.LastName;
        }
示例#4
0
        public ActionResult ExpertUpdate(ExpertVM model, IEnumerable<HttpPostedFileBase> file)
        {
            ContactService oldService = new ContactService();
            Contact old = new Contact();
            old = oldService.Find(x => x.ContactID == ExpCOnId && x.IsActive == true);
            old.IsActive = false;
            oldService.UpdateContact(old);
      
                List<FileResultItem> fileResultItems = new List<FileResultItem> { new FileResultItem { UploadPath = model.Expert.PhotoURL } };
                //RemoveAll(fileResultItems, "~/Areas/Ofiice/image/");

                _expertService.UpdateExpert(model.Expert);
                _contactService.AddContact(new Contact { ExpertID = model.Expert.ExpertID, Address = model.Contact.Address, PhoneNumber1 = model.Contact.PhoneNumber1, PhoneNumber2 = model.Contact.PhoneNumber2, IsActive = true, Email = model.Contact.Email });
        
            return RedirectToAction("ListExpertInfos");

        }
        private void BindExpertTypesDropDown(ExpertVM expert)
        {
            var expertTypes = new Dictionary <string, string>
            {
                { "E", "Външен" },
                { "I", "Вътрешен" }
            };

            this.ExpertTypeDropDown.DataSource    = new BindingSource(expertTypes, null);
            this.ExpertTypeDropDown.DisplayMember = "Value";
            this.ExpertTypeDropDown.ValueMember   = "Key";

            if (expert.ExpertType == "Вътрешен")
            {
                this.ExpertTypeDropDown.SelectedItem = this.ExpertTypeDropDown.Items[1];
            }
            else
            {
                this.ExpertTypeDropDown.SelectedItem = this.ExpertTypeDropDown.Items[0];
            }
        }
示例#6
0
        private void ExpertSearchResultGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                e.RowIndex >= 0)
            {
                if (e.ColumnIndex == 4)
                {
                    DataGridViewRow row            = this.ExpertSearchResultGrid.Rows[e.RowIndex];
                    var             selectedExpert = new ExpertVM()
                    {
                        FirstName  = row.Cells["ExpertFirstName"].Value.ToString(),
                        MiddleName = row.Cells["ExpertMiddleName"].Value.ToString(),
                        LastName   = row.Cells["ExpertLastName"].Value.ToString(),
                        ExpertType = row.Cells["ExpertType"].Value.ToString(),
                        Id         = decimal.Parse(row.Cells["ExpertId"].Value.ToString())
                    };

                    var detailsForm = new ExpertDetailsForm(selectedExpert);
                    detailsForm.ShowDialog();
                }
            }
        }