/// <summary>
        /// Udate existing contact person in client model session
        /// </summary>
        /// <param name="model">Existing contact person instance to update</param>
        /// <returns>Returns true if updating was succesfull. Otherwise false.</returns>
        public bool UpdateContactPersonToClientModelSession(ContactPersonModel model)
        {
            ClientFullModel fullModel = GetFullModelFromClientModel();

            if (fullModel != null)
            {
                var record = fullModel.KontaktneOsebe.Where(ko => ko.idKontaktneOsebe == model.idKontaktneOsebe).FirstOrDefault();
                if (record != null)
                {
                    int index = fullModel.KontaktneOsebe.IndexOf(record);
                    if (index != -1)
                    {
                        fullModel.KontaktneOsebe[index] = model;
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }

                AddValueToSession(Enums.ClientSession.ClientModel, fullModel);

                return(true);
            }
            return(false);
        }
示例#2
0
 public void saveContactPerson()
 {
     if (validationContactPerson())
     {
         if (this._contactPersonSeqNum == 0)//Add New Contact Person
         {
             if (clientModel == null)
             {
                 ListofContactPersons.Add(new ContactPersonModel {
                     ContactPersonName = this._contactPersonName, ContactPersonMobile = this._contactPersonMobile, ContactPersonMail = this._contactPersonMail, ContactPersonSeqNum = ++this.contactPersonCount, ClientSeqNum = 0
                 });
             }
             else
             {
                 ListofContactPersons.Add(new ContactPersonModel {
                     ContactPersonName = this._contactPersonName, ContactPersonMobile = this._contactPersonMobile, ContactPersonMail = this._contactPersonMail, ContactPersonSeqNum = ++this.contactPersonCount, ClientSeqNum = this.clientModel.ClientSeqNum
                 });
             }
         }
         else//Modify Contact Person
         {
             ContactPersonModel contactPerson = _listofContactPersons.FirstOrDefault(i => i.ContactPersonSeqNum == this._contactPersonSeqNum);
             contactPerson.ContactPersonName   = this._contactPersonName;
             contactPerson.ContactPersonMobile = this._contactPersonMobile;
             contactPerson.ContactPersonMail   = this._contactPersonMail;
         }
         resetContactPerson();
     }
 }
        public async Task <IActionResult> PutContactPersonModel(int id, ContactPersonModel contact)
        {
            if (id != contact.ContactId)
            {
                return(BadRequest());
            }

            contact.CompanyId = _context.Companies.Where(c => c.Name == contact.Company.Name).Single().CompanyId;
            contact.Company   = null;
            contact.UserId    = _context.ContactPeople.AsNoTracking().Where(c => c.ContactId == contact.ContactId).Single().UserId;

            _context.Entry(contact).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ContactPersonModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        /// <summary>
        /// Add new Contact person instance to Client model session
        /// </summary>
        /// <param name="model">New contact person instance to add</param>
        /// <returns>Returns true if adding was succesfull. Otherwise false.</returns>
        public bool AddContactPersonToClientModelSession(ContactPersonModel model)
        {
            ClientFullModel fullModel = GetFullModelFromClientModel();

            if (fullModel != null)
            {
                fullModel.KontaktneOsebe.Add(model);
                AddValueToSession(Enums.ClientSession.ClientModel, fullModel);

                return(true);
            }
            return(false);
        }
        private async Task <ContactPersonModel> GetContactAsync(int id)
        {
            ContactPersonModel contact = new ContactPersonModel();

            HttpResponseMessage response = await ApiHelper.GetAsync("api/contacts/" + id, HttpContext.Session.GetString("token"));

            if (response.IsSuccessStatusCode)
            {
                string userResponse = response.Content.ReadAsStringAsync().Result;
                contact = JsonConvert.DeserializeObject <ContactPersonModel>(userResponse);
            }

            return(contact);
        }
        public async Task <ActionResult> EditContact(int id, int companyId, ContactPersonModel contact)
        {
            contact.ContactId = id;
            try
            {
                HttpResponseMessage responseMessage = await ApiHelper.PutAsync("api/contacts/" + id, contact, HttpContext.Session.GetString("token"));

                return(RedirectToAction(nameof(CompanyContacts), new { id = companyId }));
            }
            catch
            {
                return(View());
            }
        }
示例#7
0
        internal override Task<object> GetInfo()
        {
            object result = null;

            var item = Item;

            result = new ContactPersonModel
            {
                ID = item.ID,
                FFP = item.FFP
            };

            return Task.FromResult(result);
        }
        /// <summary>
        /// Delete Contact person instance from client model session and add new data to session.
        /// </summary>
        /// <param name="planID">contact person ID</param>
        /// <param name="clientID">Client ID</param>
        /// <returns>Return true if delete is succesfull. Otherwise false.</returns>
        public bool DeleteContactPersonFromClientModelSession(int contactPersonID, int clientID)
        {
            ContactPersonModel model = GetContactPersonFromClientModelSession(contactPersonID, clientID);
            ClientFullModel    tmp   = GetFullModelFromClientModel();

            if (model != null && tmp != null)
            {
                bool isDeleted = tmp.KontaktneOsebe.Remove(model);
                AddValueToSession(Enums.ClientSession.ClientModel, tmp);

                return(isDeleted);
            }
            return(false);
        }
        public WebResponseContentModel <ContactPersonModel> SaveContactPersonChanges(ContactPersonModel newData)
        {
            WebResponseContentModel <ContactPersonModel> model = new WebResponseContentModel <ContactPersonModel>();

            try
            {
                model.Content = newData;
                model         = PostWebRequestData <WebResponseContentModel <ContactPersonModel> >(WebServiceHelper.SaveContactPersonChanges(), "post", model);
            }
            catch (Exception ex)
            {
                model.ValidationErrorAppSide = ConcatenateExceptionMessage(ex);
            }

            return(model);
        }
示例#10
0
        private bool AddOrEditEntityObject(bool add = false)
        {
            if (add)
            {
                model = new ContactPersonModel();

                model.idKontaktneOsebe = 0;
                model.idStranka        = clientID;
                model.tsIDOsebe        = PrincipalHelper.GetUserPrincipal().ID;
                model.ts = DateTime.Now;
            }
            else if (model == null && !add)
            {
                model = GetClientDataProviderInstance().GetContactPersonFromClientModelSession(contactPersonID, clientID);
            }
            model.NazivKontaktneOsebe = txtNaziv.Text;
            model.Telefon             = txtTelefon.Text;
            model.GSM              = txtGSM.Text;
            model.Email            = txtEmail.Text;
            model.DelovnoMesto     = txtDelovnoMesto.Text;
            model.ZaporednaStevika = CommonMethods.ParseInt(txtZaporednaStevilka.Text);
            model.Fax              = txtFax.Text;
            model.Opombe           = ASPxMemoZaznamki.Text;

            if (!dtDateRojDan.Date.Equals(DateTime.MinValue))
            {
                model.RojstniDatum = dtDateRojDan.Date;
            }

            ContactPersonModel newModel = CheckModelValidation(GetDatabaseConnectionInstance().SaveContactPersonChanges(model));

            if (newModel != null)//If new record is added we need to refresh aspxgridview. We add new record to session model.
            {
                if (add)
                {
                    return(GetClientDataProviderInstance().AddContactPersonToClientModelSession(newModel));
                }
                else
                {
                    return(GetClientDataProviderInstance().UpdateContactPersonToClientModelSession(newModel));
                }
            }
            else
            {
                return(false);
            }
        }
        private void SelectionContactPerson()
        {
            JournalsForm journal = new JournalsForm();

            JournalsPresenter <ContactPerson> presenter = new JournalsPresenter <ContactPerson>(journal, new ContactPersonJournal(journal.Grid, _contractorID));

            journal.ShowDialog();

            if (presenter.Info != null)
            {
                ContactPersonModel contact = (ContactPersonModel)presenter.Info;

                _contractPersonID           = contact.ID;
                View.ContactPerson          = contact.FFP;
                View.EnabledPowerOfAttorney = true;
            }
        }
示例#12
0
        public async Task <ActionResult> CreateContact(ContactPersonModel contact, int companyId)
        {
            contact.User       = new UserModel();
            contact.User.Login = HttpContext.Session.GetString("login");
            contact.CompanyId  = companyId;

            try
            {
                HttpResponseMessage response = await ApiHelper.PostAsync("api/contacts", contact, HttpContext.Session.GetString("token"));

                return(RedirectToAction(nameof(CompanyContacts), new { id = companyId }));
            }
            catch
            {
                return(View());
            }
        }
示例#13
0
        public int SaveContactPerson(ContactPersonModel model, bool updateRecord = true)
        {
            KontaktnaOseba_PDO kontOseba = new KontaktnaOseba_PDO();

            try
            {
                kontOseba.KontaktnaOsebaID = model.idKontaktneOsebe;
                kontOseba.StrankaID        = model.idStranka;
                kontOseba.Naziv            = model.NazivKontaktneOsebe;
                kontOseba.NazivPodpis      = model.NazivPodpis;
                kontOseba.Telefon          = model.Telefon;
                kontOseba.GSM            = model.GSM;
                kontOseba.Email          = model.Email;
                kontOseba.ts             = model.ts.Equals(DateTime.MinValue) ? (DateTime?)null : model.ts;
                kontOseba.tsIDOsebe      = model.tsIDOsebe;
                kontOseba.tsUpdate       = DateTime.Now;
                kontOseba.tsUpdateUserID = model.tsIDOsebe;
                kontOseba.Fax            = model.Fax;
                kontOseba.Opombe         = model.Opombe;
                kontOseba.IsNabava       = model.IsNabava;

                if (kontOseba.KontaktnaOsebaID == 0)
                {
                    kontOseba.ts        = DateTime.Now;
                    kontOseba.tsIDOsebe = model.tsIDOsebe;

                    context.KontaktnaOseba_PDO.Add(kontOseba);
                    context.SaveChanges();
                }
                else
                {
                    if (updateRecord)
                    {
                        KontaktnaOseba_PDO original = context.KontaktnaOseba_PDO.Where(ko => ko.KontaktnaOsebaID == kontOseba.KontaktnaOsebaID).FirstOrDefault();
                        context.Entry(original).CurrentValues.SetValues(kontOseba);
                        context.SaveChanges();
                    }
                }

                return(kontOseba.KontaktnaOsebaID);
            }
            catch (Exception ex)
            {
                throw new Exception(ValidationExceptionError.res_08, ex);
            }
        }
示例#14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (action == (int)Enums.UserAction.Edit || action == (int)Enums.UserAction.Delete)
         {
             if (contactPersonID > 0 && SessionHasValue(Enums.ClientSession.ClientModel))
             {
                 model = GetClientDataProviderInstance().GetContactPersonFromClientModelSession(contactPersonID, clientID);
                 FillForm();
             }
         }
         else if (action == (int)Enums.UserAction.Add) //action ADD
         {
             txtIdStranke.Text = clientID.ToString();
         }
         UserActionConfirmBtnUpdate(btnConfirmPopUp, action, true);
     }
     //ShowClientPopUp("'TESTINg'", 1);
     Initialize();
 }
示例#15
0
        public ActionResult Index()
        {
            ViewBag.Title = "Home Page";

            ContactPersonModel model = new ContactPersonModel();

            model.DelovnoMesto        = "sdfsdf";
            model.Email               = "*****@*****.**";
            model.Fax                 = "031123456";
            model.GSM                 = "123456789";
            model.idStranka           = 1;
            model.NazivKontaktneOsebe = "test2";
            model.Opombe              = "sdčlksjdčglkjsdgds";
            model.Telefon             = "987654321";
            model.ts               = DateTime.Now;
            model.tsIDOsebe        = 7;
            model.ZaporednaStevika = 2;

            /*EmailMessageModel model = new EmailMessageModel();
             * model.tsIDOsebe = 1;
             * model.ID = 180;
             * model.ts = DateTime.Now;
             * model.Status = 0;
             * model.MasterID = 57;
             * model.Code = "EVENT_DOGODEK";
             * PlanModel model = new PlanModel();
             * model.idPlan = 0;
             * model.idKategorija = 2;
             * model.IDStranka = 1;
             * model.Kategorija = "";
             * model.LetniZnesek = 1050;
             * model.Leto = 2017;
             * model.Stranka = "";
             * model.tsIDOsebe = 1;
             * model.ts = DateTime.Now;*/

            /*EventFullModel newEvent = new EventFullModel();
             * newEvent.idDogodek = 0;
             * newEvent.idStranka = 1;
             * newEvent.idKategorija = 1;
             * newEvent.Skrbnik = 1;
             * newEvent.Izvajalec = 1;
             * newEvent.idStatus = 1;
             * newEvent.Opis = "";
             * newEvent.DatumOtvoritve = DateTime.Now;
             * newEvent.Rok = DateTime.Now;
             * newEvent.DatumZadZaprtja = "";
             * newEvent.ts = DateTime.Now;
             * newEvent.tsIDOsebe = 1;
             * newEvent.emailModel = model;
             * /*ClientFullModel model = new ClientFullModel();
             * model.idStranka = 0;
             * model.KodaStranke = "str";
             * model.NazivPrvi = "test1";
             * model.NazivDrugi = "test2";
             * model.Naslov = "test3";
             * model.StevPoste = "test4";
             * model.NazivPoste = "test1";
             * model.Email = "test1";
             * model.Telefon = "test1";
             * model.FAX = "test1";
             * model.InternetniNalov = "test1";
             * model.KontaktnaOseba = "test1";
             * model.RokPlacila = "tes";
             * model.StrankaZaposleni = new List<ClientEmployeeModel>();
             * /*EmployeeFullModel model = new EmployeeFullModel();
             * model.idOsebe = 0;
             * model.idVloga = 3;
             * model.Ime = "Stanko";
             * model.Priimek = "Janko";
             * model.Naslov = "Stanetova 23";
             * model.TelefonGSM = "03124568";
             * model.ts = DateTime.Now;
             * model.tsIDOsebe = 1;
             * model.UporabniskoIme = "StankoJ";
             * model.Zunanji = 0;
             * model.Geslo = "JankoS";
             * model.Email = "*****@*****.**";
             * model.DelovnoMesto = "Komercialist";
             * model.DatumZaposlitve = DateTime.Now;
             * model.DatumRojstva = DateTime.Now;*/
            /*model.StrankaZaposleni = new List<ClientEmployeeModel>() { new ClientEmployeeModel() { idOsebe = 1, idStranka = 1, ts = DateTime.Now, tsIDOsebe = 1 } };*/

            /* WebResponseContentModel<ContactPersonModel> returnModel = new WebResponseContentModel<ContactPersonModel>();
             * returnModel.Content = model;
             *
             * HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://192.168.20.12/DatabaseWebService/api/client/SaveContactPersonToClient");
             * request.Method = "POST";
             * request.ContentType = "application/json; charset=utf-8";
             *
             * using (var sw = new StreamWriter(request.GetRequestStream()))
             * {
             *   string clientData = JsonConvert.SerializeObject(returnModel);
             *   sw.Write(clientData);
             *   sw.Flush();
             *   sw.Close();
             * }
             * WebResponse respone = null;
             * respone = (HttpWebResponse)request.GetResponse();
             * Stream stream = respone.GetResponseStream();
             * StreamReader reader = new StreamReader(stream);
             * string test = reader.ReadToEnd();*/

            return(View());
        }
示例#16
0
        public async Task <ResponseModel> AddUpdateContactDetails(ContactPersonModel contact)
        {
            List <SqlParameter> sp    = new List <SqlParameter>();
            SqlParameter        param = new SqlParameter("@CONTACTID", ToDBNull(contact.ContactId));

            sp.Add(param);
            param = new SqlParameter("@REFKEY", ToDBNull(contact.RefKey));
            sp.Add(param);
            param = new SqlParameter("@CONADDRESSTYPEID", ToDBNull(contact.AddressTypeId));
            sp.Add(param);
            param = new SqlParameter("@CONLOCATIONID", ToDBNull(contact.LocationId));
            sp.Add(param);
            param = new SqlParameter("@CONADDRESS", ToDBNull(contact.Address));
            sp.Add(param);
            param = new SqlParameter("@CONLOCALITY", ToDBNull(contact.Locality));
            sp.Add(param);
            param = new SqlParameter("@CONNEARBYLOCATION", ToDBNull(contact.NearLocation));
            sp.Add(param);
            param = new SqlParameter("@CONPIN", ToDBNull(contact.PinNumber));
            sp.Add(param);
            param = new SqlParameter("@CONFNAME", ToDBNull(contact.ConFirstName));
            sp.Add(param);
            param = new SqlParameter("@CONLNAME", ToDBNull(contact.ConLastName));
            sp.Add(param);
            param = new SqlParameter("@CONNUMBER", ToDBNull(contact.ConMobileNumber));
            sp.Add(param);
            param = new SqlParameter("@CONEMAIL", ToDBNull(contact.ConEmailAddress));
            sp.Add(param);
            param = new SqlParameter("@CONPANNUMBER", ToDBNull(contact.ConPanNumber));
            sp.Add(param);
            param = new SqlParameter("@CONPANFILENAME", ToDBNull(contact.ConPanFileName));
            sp.Add(param);
            param = new SqlParameter("@CONVOTERID", ToDBNull(contact.ConVoterId));
            sp.Add(param);
            param = new SqlParameter("@CONVOTERIDFILENAME", ToDBNull(contact.ConVoterIdFileName));
            sp.Add(param);
            param = new SqlParameter("@CONADHAARNUMBER", ToDBNull(contact.ConAdhaarNumber));
            sp.Add(param);
            param = new SqlParameter("@CONADHAARFILENAME", ToDBNull(contact.ConAdhaarFileName));
            sp.Add(param);
            param = new SqlParameter("@ACTION", (object)contact.EventAction);
            sp.Add(param);
            param = new SqlParameter("@USER", ToDBNull(contact.UserId));
            sp.Add(param);
            param = new SqlParameter("@ISUSER", ToDBNull(contact.IsUser));
            sp.Add(param);
            param = new SqlParameter("@USERTYPEID", ToDBNull(contact.UserTypeId));
            sp.Add(param);
            param = new SqlParameter("@DefaultPWD", ToDBNull(contact.Password));
            sp.Add(param);
            param = new SqlParameter("@CompId", ToDBNull(contact.CompanyId));
            sp.Add(param);
            param = new SqlParameter("@IsSingleCenter", ToDBNull(contact.IsSingleCenter));
            sp.Add(param);
            var sql = "USPADDOREDITCONTACTS @CONTACTID,@REFKEY,@CONADDRESSTYPEID,@CONLOCATIONID,@CONADDRESS,@CONLOCALITY ,@CONNEARBYLOCATION,@CONPIN," +
                      "@CONFNAME,@CONLNAME,@CONNUMBER,@CONEMAIL,@CONPANNUMBER,@CONPANFILENAME,@CONVOTERID,@CONVOTERIDFILENAME,@CONADHAARNUMBER,@CONADHAARFILENAME,@ACTION,@USER,@ISUSER,@USERTYPEID, @DefaultPWD,@CompId,@IsSingleCenter";
            var res = await _context.Database.SqlQuery <ResponseModel>(sql, sp.ToArray()).FirstOrDefaultAsync();

            if (res.ResponseCode == 0)
            {
                res.IsSuccess = true;
            }
            else
            {
                res.IsSuccess = false;
            }
            return(res);
        }
        protected override async Task SaveAsync()
        {
            try
            {
                var FFP          = View.FFP;
                var phone        = View.Phone;
                var email        = View.Email;
                var address      = View.Address;
                var additionally = View.Additionally;


                if (string.IsNullOrWhiteSpace(FFP))
                {
                    throw new ArgumentNullException(null, "Вы не ввели имя контактного лица!");
                }


                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        await context.ContactPerson.Where(cn => cn.ID == (Guid)Identifier).UpdateAsync(cn => new ContactPersonModel
                        {
                            FFP          = FFP,
                            Phone        = GetNullValue(phone),
                            Email        = GetNullValue(email),
                            Address      = GetNullValue(address),
                            Additionally = GetNullValue(additionally)
                        });
                    }
                    else
                    {
                        Guid id = ConsistentGuid.CreateGuid();
                        ContactPersonModel insertContactPersonInfo = new ContactPersonModel
                        {
                            ID            = id,
                            FFP           = FFP,
                            Phone         = GetNullValue(phone),
                            Email         = GetNullValue(email),
                            Address       = GetNullValue(address),
                            Additionally  = GetNullValue(additionally),
                            ID_сontractor = _contractorID
                        };
                        context.ContactPerson.Add(insertContactPersonInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertContactPersonInfo.ID;
                        _powerOfAttorneyJournal.ContactPersonID = id;
                    }
                }
                if (!openView)
                {
                    View.Close();
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
示例#18
0
        // GET: Contact/Details/5
        public async Task <ActionResult> Details(int id)
        {
            ContactPersonModel contact = await GetContactAsync(id);

            return(View(contact));
        }
        public async Task <ActionResult <ContactPersonModel> > PostContactPersonModel(ContactPersonModel contact)
        {
            contact.IsDeleted = false;
            contact.UserId    = _context.Users.Where(u => u.Login == contact.User.Login).Single().UserId;
            contact.User      = null;

            _context.ContactPeople.Add(contact);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetContactPersonModel", new { id = contact.ContactId }, contact));
        }