Ejemplo n.º 1
0
        public BusinessPartnerTypeResponse SetStatusDeleted(Guid identifier)
        {
            BusinessPartnerTypeResponse response = new BusinessPartnerTypeResponse();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();

                SqliteCommand insertCommand = new SqliteCommand();
                insertCommand.Connection = db;

                //Use parameterized query to prevent SQL injection attacks
                insertCommand.CommandText =
                    "UPDATE BusinessPartnerTypes SET ItemStatus = @ItemStatus WHERE Identifier = @Identifier";
                insertCommand.Parameters.AddWithValue("@ItemStatus", ItemStatus.Deleted);
                insertCommand.Parameters.AddWithValue("@Identifier", identifier);
                try
                {
                    insertCommand.ExecuteReader();
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage = error.Message;
                    response.Success        = false;
                    response.Message        = error.Message;
                    return(response);
                }
                db.Close();

                response.Success = true;
                return(response);
            }
        }
Ejemplo n.º 2
0
        public BusinessPartnerTypeResponse Create(BusinessPartnerTypeViewModel businessPartnerType)
        {
            BusinessPartnerTypeResponse response = new BusinessPartnerTypeResponse();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();

                SqliteCommand insertCommand = db.CreateCommand();
                insertCommand.CommandText = SqlCommandInsertPart;

                try
                {
                    insertCommand = AddCreateParameters(insertCommand, businessPartnerType);
                    insertCommand.ExecuteNonQuery();
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage = error.Message;
                    response.Success        = false;
                    response.Message        = error.Message;
                    return(response);
                }
                db.Close();

                response.Success = true;
                return(response);
            }
        }
        public BusinessPartnerTypeResponse Create(BusinessPartnerTypeViewModel re)
        {
            BusinessPartnerTypeResponse response = new BusinessPartnerTypeResponse();

            try
            {
                response = WpfApiHandler.SendToApi <BusinessPartnerTypeViewModel, BusinessPartnerTypeResponse>(re, "Create");
            }
            catch (Exception ex)
            {
                response.BusinessPartnerType = new BusinessPartnerTypeViewModel();
                response.Success             = false;
                response.Message             = ex.Message;
            }

            return(response);
        }
        public BusinessPartnerTypeResponse Delete(Guid identifier)
        {
            BusinessPartnerTypeResponse response = new BusinessPartnerTypeResponse();

            try
            {
                BusinessPartnerTypeViewModel re = new BusinessPartnerTypeViewModel();
                re.Identifier = identifier;
                response      = WpfApiHandler.SendToApi <BusinessPartnerTypeViewModel, BusinessPartnerTypeResponse>(re, "Delete");
            }
            catch (Exception ex)
            {
                response.BusinessPartnerType = new BusinessPartnerTypeViewModel();
                response.Success             = false;
                response.Message             = ex.Message;
            }

            return(response);
        }
        public BusinessPartnerTypeResponse Create(BusinessPartnerTypeViewModel re)
        {
            BusinessPartnerTypeResponse response = new BusinessPartnerTypeResponse();

            try
            {
                BusinessPartnerType addedBusinessPartnerType = unitOfWork.GetBusinessPartnerTypeRepository().Create(re.ConvertToBusinessPartnerType());
                unitOfWork.Save();
                response.BusinessPartnerType = addedBusinessPartnerType.ConvertToBusinessPartnerTypeViewModel();
                response.Success             = true;
            }
            catch (Exception ex)
            {
                response.BusinessPartnerType = new BusinessPartnerTypeViewModel();
                response.Success             = false;
                response.Message             = ex.Message;
            }

            return(response);
        }
Ejemplo n.º 6
0
        public JsonResult Delete([FromBody] BusinessPartnerTypeViewModel businessPartnerType)
        {
            BusinessPartnerTypeResponse response = new BusinessPartnerTypeResponse();

            try
            {
                response = this.businessPartnerTypeService.Delete(businessPartnerType.Identifier);
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
                Console.WriteLine(ex.Message);
            }

            return(Json(response, new Newtonsoft.Json.JsonSerializerSettings()
            {
                Formatting = Newtonsoft.Json.Formatting.Indented
            }));
        }
        public BusinessPartnerTypeResponse Delete(Guid identifier)
        {
            BusinessPartnerTypeResponse response = new BusinessPartnerTypeResponse();

            try
            {
                BusinessPartnerType deletedBusinessPartnerType = unitOfWork.GetBusinessPartnerTypeRepository().Delete(identifier);

                unitOfWork.Save();

                response.BusinessPartnerType = deletedBusinessPartnerType.ConvertToBusinessPartnerTypeViewModel();
                response.Success             = true;
            }
            catch (Exception ex)
            {
                response.BusinessPartnerType = new BusinessPartnerTypeViewModel();
                response.Success             = false;
                response.Message             = ex.Message;
            }

            return(response);
        }
Ejemplo n.º 8
0
        public BusinessPartnerTypeResponse GetBusinessPartnerType(Guid identifier)
        {
            BusinessPartnerTypeResponse  response            = new BusinessPartnerTypeResponse();
            BusinessPartnerTypeViewModel businessPartnerType = new BusinessPartnerTypeViewModel();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();
                try
                {
                    SqliteCommand selectCommand = new SqliteCommand(
                        SqlCommandSelectPart +
                        "FROM BusinessPartnerTypes " +
                        "WHERE Identifier = @Identifier;", db);
                    selectCommand.Parameters.AddWithValue("@Identifier", identifier);

                    SqliteDataReader query = selectCommand.ExecuteReader();

                    if (query.Read())
                    {
                        BusinessPartnerTypeViewModel dbEntry = Read(query);
                        businessPartnerType = dbEntry;
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage      = error.Message;
                    response.Success             = false;
                    response.Message             = error.Message;
                    response.BusinessPartnerType = new BusinessPartnerTypeViewModel();
                    return(response);
                }
                db.Close();
            }
            response.Success             = true;
            response.BusinessPartnerType = businessPartnerType;
            return(response);
        }