internal void AssignInitialValueAsync(List <BarcodeModel> _alerts)
        {
            try
            {
                ConstantManager.VerifiedBarcodes = _alerts;

                LoadOwnderAsync();
                LoadAssetSizeAsync();
                LoadAssetTypeAsync();
                var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());

                foreach (var item in _alerts)
                {
                    AssetTypeModel selectedType  = null;
                    AssetSizeModel selectedSize  = null;
                    OwnerModel     selectedOwner = OwnerCollection.Where(x => x.FullName == item?.Kegs?.Partners?.FirstOrDefault()?.FullName).FirstOrDefault();

                    if (selectedOwner != null)
                    {
                        RealmDb.Write(() =>
                        {
                            selectedOwner.HasInitial = true;
                        });
                    }
                    if (item.Tags.Count > 2)
                    {
                        selectedType = TypeCollection.Where(x => x.AssetType == item.Tags?[2]?.Value).FirstOrDefault();

                        RealmDb.Write(() =>
                        {
                            selectedType.HasInitial = true;
                        });
                    }
                    if (item.Tags.Count > 3)
                    {
                        selectedSize = SizeCollection.Where(x => x.AssetSize == item.Tags?[3]?.Value).FirstOrDefault();
                        RealmDb.Write(() =>
                        {
                            selectedSize.HasInitial = true;
                        });
                    }

                    MaintenaceCollection.Add(
                        new MoveMaintenanceAlertModel
                    {
                        UOwnerCollection = OwnerCollection.ToList(),
                        USizeCollection  = SizeCollection.ToList(),
                        UTypeCollection  = TypeCollection.ToList(),
                        BarcodeId        = item.Barcode,
                        SelectedUOwner   = selectedOwner ?? selectedOwner,
                        SelectedUSize    = selectedSize ?? selectedSize,
                        SelectedUType    = selectedType ?? selectedType
                    });
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
 public MessageOwnerPageViewModel(OwnerModel obj)
 {
     this.Owner = obj;
     LoadMessage();
     ImageCommand = new Command(ImageCommandExecuted);
     SendCommand  = new Command(SendCommandExecuted);
 }
        public PetModel AddOrEditPet(PetModel model, OwnerModel ownerModel)
        {
            OwnerService ownerLogic = new OwnerService();
            var          owner      = ownerLogic.AddOrEditOwner(ownerModel);

            Pet pet = new Pet();

            using (var db = new PawsAndClawsEntities())
            {
                pet = db.Pets.Where(i => i.PetId == model.PetId).FirstOrDefault();

                if (pet != null)
                {
                    pet.PetName = model.PetName;
                    pet.Type    = model.Type;
                    pet.OwnerId = model.OwnerId;
                }
                else
                {
                    model.OwnerId = owner.OwnerId;
                    pet           = db.Pets.Add(model.ToDTO());
                }

                db.SaveChanges();
            }

            return(new PetModel(pet));
        }
示例#4
0
        public async Task <IActionResult> Edit(int id, [Bind("OwnerId,OwnerName")] OwnerModel ownerModel)
        {
            if (id != ownerModel.OwnerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ownerModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OwnerModelExists(ownerModel.OwnerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(ownerModel));
        }
示例#5
0
        private async void DeleteOwnerCommandExecuted(OwnerModel obj)
        {
            bool answer = await App.Current.MainPage.DisplayAlert("Eliminar", $"Desea eliminar al propietario: {obj.Name}", "Si", "No");

            if (answer)
            {
                var db       = DbContext.Instance.GetAdministrator();
                var response = await client.Delete <ListResponse>($"administrator/delowner?IdOwner={obj.IdOwner}&IdAdmin={db.IdAdmin}&Name={obj.Name}");

                if (response != null)
                {
                    if (response.Result && response.Count > 0)
                    {
                        SnackSucces("Se elimino correctamente", "KYA", Helpers.TypeSnackBar.Top);
                        LoadOwner();
                    }
                    else
                    {
                        SnackError(response.Message, "Error", Helpers.TypeSnackBar.Top);
                    }
                }
                else
                {
                    SnackError("hubo un error intentelo mas tarde", "Error", Helpers.TypeSnackBar.Top);
                }
            }
        }
示例#6
0
        public void InsertOwner(OwnerModel owner)
        {
            owner.IdOwner = Guid.NewGuid();

            dbContext.Owners.InsertOnSubmit(MapModelToDbObject(owner));
            dbContext.SubmitChanges();
        }
示例#7
0
        public async Task <OwnerModel> CreateOwner(OwnerModel model)
        {
            using (IDbConnection connection = new MySqlConnection(_connectionString))
            {
                connection.Open();
                var p = new DynamicParameters();
                p.Add("@_Id", model.Id);
                p.Add("@_FirstName", model.FirstName);
                p.Add("@_LastName", model.LastName);
                p.Add("@_Address", model.Address);
                p.Add("@_City", model.City);
                p.Add("@_State", model.State);
                p.Add("@_PostCode", model.PostCode);
                p.Add("@_BankName", model.BankName);
                p.Add("@_BankRoutingNumber", model.BankRoutingNumber);
                p.Add("@_BankAccount", model.BankAccount);
                p.Add("@_Phone", model.Phone);
                //we always have userId, so it is update.
                var result = await connection.ExecuteAsync("sp_create_owner", p, commandType : CommandType.StoredProcedure);

                if (result != 1)
                {
                    return(null);
                }
            }

            return(model);
        }
示例#8
0
        private void ConfirmButton_Click(object sender, RoutedEventArgs e)
        {
            OwnerModel owner = (OwnerModel)OwnerList.SelectedItem;

            if (owner != null)
            {
                Revenue            = new RevenueModel();
                Revenue.Staff      = PublicVariables.Staff;
                Revenue.Store      = PublicVariables.Store;
                Revenue.Date       = DateTime.Now;
                Revenue.TotalMoney = (decimal)RevenueValue.Value;

                GlobalConfig.RevenueValidator = new RevenueValidator();
                ValidationResult result = GlobalConfig.RevenueValidator.Validate(Revenue);

                if (result.IsValid == false)
                {
                    MessageBox.Show(result.Errors[0].ErrorMessage);
                }
                else
                {
                    GlobalConfig.Connection.AddRevenueToTheDatabase(Revenue, owner);
                    SetInitialValues();
                }
            }
            else
            {
                MessageBox.Show("Select Owner Please");
            }
        }
示例#9
0
        public async Task <HttpResponseMessage> CreateOwner([FromBody] OwnerModel model)
        {
            if (model == null || string.IsNullOrEmpty(model.Email) ||
                (string.IsNullOrEmpty(model.FirstName) && string.IsNullOrEmpty(model.LastName)))
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
            //new user
            if (model.Id < 0)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var createResult = await UserManager.CreateAsync(user, _tempPassword);

                //no matter whether it is successful or not
                var userId = await _adminManager.CheckUserExistence(model.Email);

                if (userId < 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError));
                }
                model.Id = userId;
            }

            var result = await _adminManager.CreateOwner(model);

            if (result)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, model));
            }
            return(Request.CreateResponse(HttpStatusCode.BadRequest));
        }
示例#10
0
        public ActionResult Create()
        {
            //TO DO: These are just hard coded data. We need to get these data from the database
            OwnerModel ownerModel = new OwnerModel();

            ownerModel.StateList = new List <StateModel>()
            {
                new StateModel()
                {
                    intStateID = 1, strState = "OH"
                },
                new StateModel()
                {
                    intStateID = 2, strState = "KY"
                }
            };

            ownerModel.GenderList = new List <GenderModel>()
            {
                new GenderModel()
                {
                    intGenderID = 1, strGender = "Female"
                },
                new GenderModel()
                {
                    intGenderID = 2, strGender = "Male"
                }
            };

            return(View(ownerModel));
        }
示例#11
0
        public OwnerModel AddOrEditOwner(OwnerModel model)
        {
            Owner owner = new Owner();

            using (var db = new PawsAndClawsEntities())
            {
                owner = db.Owners.Where(i => i.OwnerId == model.OwnerId).FirstOrDefault();

                if (owner != null)
                {
                    owner.First   = model.First;
                    owner.Last    = model.Last;
                    owner.Phone   = model.Phone;
                    owner.Address = model.Address;
                }
                else
                {
                    owner = db.Owners.Add(model.ToDTO());
                }

                db.SaveChanges();
            }

            return(new OwnerModel(owner));
        }
示例#12
0
        public async Task <OwnerModel> GetOwnerWithParentOwnerCodeAsync(Guid id)
        {
            if (id == Guid.Empty || id == null)
            {
                throw new TMNotValidException(string.Format(ErrorMessages.PropertyIsRequired, nameof(id)));
            }

            OwnerModel existingEntity = mappingManager.Create(await context.OwnerRepository.FindAsync(id));

            if (existingEntity == null)
            {
                throw new TMNotFoundException(string.Format(ErrorMessages.ObjectNotFound, nameof(Owner)));
            }

            if (existingEntity.IdMainOwner != null)
            {
                Owner parent = await context.OwnerRepository.FindAsync(existingEntity.IdMainOwner);

                if (parent != null && !string.IsNullOrEmpty(parent.OwnerCode))
                {
                    existingEntity.OwnerCodeOfParent = parent.OwnerCode;
                }
            }

            return(existingEntity);
        }
示例#13
0
        public async Task <ActionResult <OwnerViewModel> > Post(OwnerViewModel createOwner)
        {
            OwnerModel owner     = _mapper.MapObjectTo <OwnerModel>(createOwner);
            bool       isCreated = await _ownerService.CreateOwnerAsync(owner);

            return(isCreated ? Created(Url.Action(nameof(GetOwnerById), new { id = owner.Id }), _mapper.MapObjectTo <OwnerViewModel>(owner)) as ActionResult : BadRequest() as ActionResult);
        }
示例#14
0
        // GET: Owners/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                if (User.Identity.IsAuthenticated)
                {
                    return(RedirectToAction("Create", "Owners"));
                }
                else
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
            }
            if (User.Identity.IsAuthenticated && id == 0)
            {
                return(RedirectToAction("Create", "Owners"));
            }
            OwnerModel ownerModel = db.Owner.Find(id);

            if (ownerModel == null)
            {
                return(HttpNotFound());
            }
            return(View(ownerModel));
        }
        private async void AddSaveOwnerCommandExecuted()
        {
            try
            {
                if (string.IsNullOrWhiteSpace(Name))
                {
                    SnackError("Ingrese un nombre", "Error", Helpers.TypeSnackBar.Top);
                    return;
                }
                if (string.IsNullOrWhiteSpace(Address))
                {
                    SnackError("Ingrese una direccion", "Error", Helpers.TypeSnackBar.Top);
                    return;
                }
                if (string.IsNullOrWhiteSpace(User))
                {
                    SnackError("Ingrese un usuario", "Error", Helpers.TypeSnackBar.Top);
                    return;
                }
                if (string.IsNullOrWhiteSpace(Phone))
                {
                    SnackError("Ingrese un telefono", "Error", Helpers.TypeSnackBar.Top);
                    return;
                }
                var admin = DbContext.Instance.GetAdministrator();
                var o     = new OwnerModel();
                o.Password   = Encrypt.Crypt(User);
                o.IdAdmin    = admin.IdAdmin;
                o.Address    = Address;
                o.Name       = Name;
                o.IconString = string.Empty;
                o.Phone      = Phone;
                o.User       = Encrypt.Crypt(User);
                o.Icon       = null;
                var response = await client.Post <ListResponse, OwnerModel>(o, $"administrator/insowner");

                if (response != null)
                {
                    if (response.Result && response.Count > 0)
                    {
                        await PopupNavigation.Instance.PopAllAsync(true);

                        MessagingCenter.Send <AddOwnerPopupPageViewModel>(this, "home");
                        SnackSucces("Se agrego correctamente", "KyA", TypeSnackBar.Top);
                    }
                    else
                    {
                        SnackError(response.Message, "Error", TypeSnackBar.Top);
                    }
                }
                else
                {
                    SnackError("Hubo un error intentelo mas tarde", "Error", TypeSnackBar.Top);
                }
            }
            catch (Exception ex)
            {
            }
        }
示例#16
0
        public ActionResult DeleteConfirmed(int id)
        {
            OwnerModel ownerModel = db.Owner.Find(id);

            db.Owner.Remove(ownerModel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#17
0
        public async Task UpdateAsync(OwnerModel owner, string currentUser)
        {
            ValidateOwner(owner);
            if (owner.IdOwner == null || owner.IdOwner == Guid.Empty)
            {
                throw new TMNotValidException(string.Format(ErrorMessages.PropertyIsRequired, nameof(owner.IdOwner)));
            }

            ValidateCurrentUser(currentUser);

            bool isOwnerCodeUnique = await context.OwnerRepository.IsOwnerCodeUniqueAsync(owner.IdOwner, owner.OwnerCode);

            if (!isOwnerCodeUnique)
            {
                throw new TMNotValidException(string.Format(ErrorMessages.PropertyIsIncorrect, nameof(owner.OwnerCode)));
            }

            var currentOwner = await context.OwnerRepository.FindAsync(owner.IdOwner);

            if (currentOwner == null)
            {
                throw new TMNotFoundException(string.Format(ErrorMessages.ObjectNotFound, nameof(owner)));
            }

            if (!string.IsNullOrEmpty(owner.OwnerCodeOfParent))
            {
                Owner newMainOwner = await context.OwnerRepository.FindOwnerByOwnerCodeAsync(owner.OwnerCodeOfParent);

                if (newMainOwner == null || newMainOwner.IdMainOwner != null || newMainOwner.SystemCode != owner.SystemCode)
                {
                    throw new TMNotValidException(string.Format(ErrorMessages.PropertyIsIncorrect, nameof(owner.OwnerCodeOfParent)));
                }

                currentOwner.IdMainOwner = newMainOwner.IdOwner;
            }

            //This code checks if owner is a branch of a bank and if they have different system codes potentially
            //this whole changing of system code option could be removed (depending on what Patrick says).
            if (owner.IdMainOwner.HasValue)
            {
                Owner mainOwner = await context.OwnerRepository.FindAsync((Guid)owner.IdMainOwner);

                if (mainOwner == null || string.IsNullOrEmpty(mainOwner.SystemCode) || mainOwner.SystemCode != owner.SystemCode)
                {
                    throw new TMNotValidException(string.Format(ErrorMessages.PropertyIsIncorrect, nameof(owner.SystemCode)));
                }
            }

            currentOwner.OwnerCode  = owner.OwnerCode;
            currentOwner.SystemCode = owner.SystemCode;
            currentOwner.Name1      = owner.Name1;
            currentOwner.Name2      = owner.Name2;
            currentOwner.ModifyUser = currentUser;
            currentOwner.ModifyDate = dateTimeManager.GetDateTime();

            context.OwnerRepository.Context.Entry(currentOwner).OriginalValues[nameof(Owner.RowVersion)] = owner.RowVersion;
            await context.SaveChangesAsync();
        }
示例#18
0
        public ActionResult OwnersPalette()
        {
            // This is where we'd authenticate with the owner service to receive our Owner object
            OwnerModel model = new OwnerModel();

            model.BxgOwner = (BGO.OwnerWS.Owner)Session["BXGOwner"];
            HydrateModel(model);
            return(PartialView("OwnersPalette", model));
        }
示例#19
0
 public ActionResult Edit([Bind(Include = "ID,FirstName,LastName,Phone,Email")] OwnerModel ownerModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ownerModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(ownerModel));
 }
示例#20
0
        public async Task <bool> CreateOwner(OwnerModel model)
        {
            if (string.IsNullOrEmpty(model.Email))
            {
                return(false);
            }
            var result = _repository.CreateOwner(model);

            return(result != null);
        }
示例#21
0
        public async Task <IActionResult> Create([Bind("OwnerId,OwnerName")] OwnerModel ownerModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(ownerModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(ownerModel));
        }
示例#22
0
 public async Task Update(OwnerModel entity)
 {
     try
     {
         await unitOfWork.GetConnection().QueryAsync(UpdateSql, entity, unitOfWork.GetTransaction());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#23
0
 public DataToPDF(OwnerModel owner, CustommerModel customer, List <WorkflowModel> workfow, List <ConsuptionModel> consuption, string savePath, int wSum, int cSum, int totalSum)
 {
     this._Owner      = owner;
     this._Customer   = customer;
     this._Workfow    = workfow;
     this._Consuption = consuption;
     this._Save       = savePath;
     this._WSum       = wSum;
     this._CSum       = cSum;
     this._TotalSum   = totalSum;
 }
        public async Task <IActionResult> Create([FromForm] OwnerModel owner)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            ;
            await _ownerService.AddOwner(owner);

            return(CreatedAtAction("GetOwner", new { id = owner.Id }, owner));
        }
 public IActionResult Edit(OwnerModel obj)
 {
     ViewData["UserNameM"]  = HttpContext.Session.GetString("name") + " " + HttpContext.Session.GetString("surname");
     ViewData["department"] = HttpContext.Session.GetString("department");
     if (ModelState.IsValid)
     {
         ownerRepository.Update(obj);
         return(RedirectToAction("Index"));
     }
     return(View(obj));
 }
示例#26
0
 public string PostOwner(OwnerModel ownerModel)
 {
     try
     {
         return(_repository.PostOwner(ownerModel));
     }
     catch (Exception ee)
     {
         throw ee;
     }
 }
示例#27
0
 public void InsertOwner(OwnerModel user)
 {
     try
     {
         connection.DeleteAll <OwnerModel>();
         connection.Insert(user);
     }
     catch (Exception ex)
     {
     }
 }
示例#28
0
        public async Task <ActionResult <OwnerModel> > UpdateOwnerAsync(long id, OwnerViewModel updateOwner)
        {
            OwnerModel owner   = _mapper.MapObjectTo <OwnerModel>(updateOwner);
            bool       isSaved = await _ownerService.UpdateOwnerAsync(id, owner);

            if (!isSaved)
            {
                return(NotFound());
            }
            return(Ok(isSaved));
        }
示例#29
0
 private T InternalGetBeforeEditValue(DataRow dataRow, DataRow translatedDataRow)
 {
     OwnerModel.SuspendEditingValue();
     try
     {
         return(InternalGetValue(dataRow, translatedDataRow));
     }
     finally
     {
         OwnerModel.ResumeEditingValue();
     }
 }
示例#30
0
        public AppointmentModel AddOrEditAppointment(AppointmentViewModel model)
        {
            PetModel petModel = new PetModel()
            {
                PetId   = model.PetId,
                PetName = model.PetName,
                Type    = model.Type,
                OwnerId = model.OwnerId
            };

            OwnerModel ownerModel = new OwnerModel()
            {
                OwnerId = model.OwnerId,
                First   = model.First,
                Last    = model.Last,
                Phone   = model.Phone,
                Address = model.Address
            };

            AppointmentModel appointmentModel = new AppointmentModel()
            {
                AppointmentId     = model.AppointmentId,
                PetId             = model.PetId,
                AppointmentDate   = model.AppointmentDate,
                AppointmentReason = model.AppointmentReason
            };

            PetService petLogic = new PetService();
            var        pet      = petLogic.AddOrEditPet(petModel, ownerModel);

            Appointment appointment = new Appointment();

            using (var db = new PawsAndClawsEntities())
            {
                appointment = db.Appointments.Where(i => i.AppointmentId == model.AppointmentId).FirstOrDefault();

                if (appointment != null)
                {
                    appointment.AppointmentDate   = model.AppointmentDate;
                    appointment.AppointmentReason = model.AppointmentReason;
                    appointment.PetId             = model.PetId;
                }
                else
                {
                    appointmentModel.PetId = pet.PetId;
                    appointment            = db.Appointments.Add(appointmentModel.ToDTO());
                }

                db.SaveChanges();
            }

            return(appointmentModel);
        }