Example #1
0
        public Result <CafeDTO> GetByOwnerId(string ownerId)
        {
            Result <CafeDTO> result;
            CafeDTO          cafeDTO;

            try
            {
                using (RCADataContext context = new RCADataContext())
                {
                    cafeDTO = Mapper.Map <Cafe, CafeDTO>(context.Cafe.Where(w => w.OwnerId == ownerId).FirstOrDefault());
                    result  = new Result <CafeDTO>(cafeDTO);
                }
            }
            catch (Exception ex)
            {
                result = new Result <CafeDTO>(false, ResultType.Error, $"CafeService.GetByOwnerID Method Ex: {ex.ToString()}");
            }
            return(result);
        }
Example #2
0
        public Result <CafeDTO> GetByExternalCode(string externalCode)
        {
            Result <CafeDTO> result;

            try
            {
                using (RCADataContext context = new RCADataContext())
                {
                    Cafe    cafe    = context.Cafe.Where(w => w.AppSecret == externalCode).FirstOrDefault();
                    CafeDTO cafeDTO = Mapper.Map <Cafe, CafeDTO>(cafe);
                    result = new Result <CafeDTO>(cafeDTO);
                }
            }
            catch (Exception ex)
            {
                result = new Result <CafeDTO>(false, ResultType.Error, $"CafeService.GetByExternalCode Method Ex: {ex.ToString()}");
            }
            return(result);
        }